Fix scroll

This commit is contained in:
Lucas Lima 2020-12-17 10:52:16 -03:00
parent 91f6ab4860
commit 808b87145b
No known key found for this signature in database
GPG key ID: 049CCC5A365B00D2
3 changed files with 6 additions and 4 deletions

View file

@ -67,9 +67,7 @@ open class LevelFragment : CommonLevelFragment(R.layout.fragment_level) {
eventObserver.observe(
viewLifecycleOwner,
{
if ((it == Event.StartNewGame || it == Event.ResumeGame) &&
recyclerGrid.scrollY == 0 &&
recyclerGrid.scrollX == 0) {
if (!gameViewModel.hasPlantedMines()) {
recyclerGrid.post {
levelSetup.value?.let { minefield ->
val size = dimensionRepository.areaSizeWithPadding()

View file

@ -384,6 +384,10 @@ open class GameViewModel(
gameController.revealAllEmptyAreas()
}
fun hasPlantedMines(): Boolean {
return gameController.mines().isNotEmpty()
}
fun revealRandomMine(): Boolean {
return if (gameController.revealRandomMine()) {
if (tipRepository.removeTip()) {

View file

@ -58,7 +58,7 @@ class WatchLevelFragment : CommonLevelFragment(R.layout.fragment_level) {
eventObserver.observe(
viewLifecycleOwner,
{
if (it == Event.StartNewGame || it == Event.ResumeGame) {
if (!gameViewModel.hasPlantedMines()) {
recyclerGrid.post {
levelSetup.value?.let { minefield ->
val size = dimensionRepository.areaSizeWithPadding()