From a1178a198b48d134259df39af26f2380cb761293 Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Thu, 17 Dec 2020 10:10:20 -0300 Subject: [PATCH] Fix scroll --- .../java/dev/lucasnlm/antimine/level/view/LevelFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt b/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt index c4f05783..37353b88 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt @@ -67,13 +67,16 @@ open class LevelFragment : CommonLevelFragment(R.layout.fragment_level) { eventObserver.observe( viewLifecycleOwner, { - if (it == Event.StartNewGame || it == Event.ResumeGame) { + if ((it == Event.StartNewGame || it == Event.ResumeGame) && + recyclerGrid.scrollY == 0 && + recyclerGrid.scrollX == 0) { recyclerGrid.post { levelSetup.value?.let { minefield -> val size = dimensionRepository.areaSizeWithPadding() val actionBarSize = dimensionRepository.actionBarSize() val dx = minefield.width * size * 0.25f val dy = (minefield.height * size + actionBarSize) * 0.25f - size * 3 + recyclerGrid.smoothScrollBy(dx.toInt(), dy.toInt(), null, 200) } }