Fix scroll

This commit is contained in:
Lucas Lima 2020-12-17 10:10:20 -03:00
parent 6a16fa789d
commit a1178a198b
No known key found for this signature in database
GPG key ID: 049CCC5A365B00D2

View file

@ -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)
}
}