From c9f7c1ea425f473f2e0a27f5c6b6e6fde7e48bde Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Tue, 23 Jun 2020 00:30:33 -0300 Subject: [PATCH] Fix bugs --- app/src/main/AndroidManifest.xml | 1 - .../dev/lucasnlm/antimine/GameActivity.kt | 34 ------------------- .../antimine/level/view/LevelFragment.kt | 8 +++-- .../common/level/viewmodel/GameViewModel.kt | 4 +-- .../level/widget/FixedGridLayoutManager.java | 2 +- 5 files changed, 8 insertions(+), 41 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b05b06b3..aa8efffe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -58,7 +58,6 @@ android:saveEnabled="false" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" - android:configChanges="screenSize|orientation" android:theme="@style/AppTheme.NoActionBar"> diff --git a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt index 4d530657..4637aebf 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt @@ -504,40 +504,6 @@ class GameActivity : AppCompatActivity() { ) } } - Event.ResumeVictory -> { - val score = Score( - rightMines, - totalMines, - totalArea - ) - status = Status.Over(currentTime, score) - invalidateOptionsMenu() - viewModel.stopClock() - - if (viewModel.isCurrentGame()) { - waitAndShowEndGameDialog( - victory = true, - await = true - ) - } - } - Event.ResumeGameOver -> { - val score = Score( - rightMines, - totalMines, - totalArea - ) - status = Status.Over(currentTime, score) - invalidateOptionsMenu() - viewModel.stopClock() - - if (viewModel.isCurrentGame()) { - waitAndShowEndGameDialog( - victory = false, - await = true - ) - } - } else -> { } } } 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 d0b19129..23508536 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 @@ -48,6 +48,7 @@ open class LevelFragment : CommonLevelFragment() { val horizontalPadding = calcHorizontalPadding(it.width) val verticalPadding = calcVerticalPadding(it.height) layoutManager = makeNewLayoutManager(it.width) + setHasFixedSize(true) setPadding(horizontalPadding, verticalPadding, 0, 0) } } @@ -64,15 +65,16 @@ open class LevelFragment : CommonLevelFragment() { viewLifecycleOwner, Observer { when (it) { + Event.Pause, Event.ResumeGameOver, Event.GameOver, Event.Victory, Event.ResumeVictory -> areaAdapter.setClickEnabled(false) Event.Running, + Event.Resume, Event.ResumeGame, Event.StartNewGame -> areaAdapter.setClickEnabled(true) - else -> { - } + null -> { } } } ) @@ -98,10 +100,10 @@ open class LevelFragment : CommonLevelFragment() { recyclerGrid.apply { val horizontalPadding = calcHorizontalPadding(levelSetup.width) val verticalPadding = calcVerticalPadding(levelSetup.height) - setHasFixedSize(true) addItemDecoration(SpaceItemDecoration(R.dimen.field_padding)) setPadding(horizontalPadding, verticalPadding, 0, 0) layoutManager = makeNewLayoutManager(levelSetup.width) + setHasFixedSize(true) adapter = areaAdapter alpha = 0.0f diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt index 1f377b1e..f3e72d92 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt @@ -92,8 +92,8 @@ class GameViewModel @ViewModelInject constructor( refreshAll() when { - levelFacade.hasAnyMineExploded() -> eventObserver.postValue(Event.ResumeGameOver) - levelFacade.checkVictory() -> eventObserver.postValue(Event.ResumeVictory) + levelFacade.hasAnyMineExploded() -> eventObserver.postValue(Event.GameOver) + levelFacade.checkVictory() -> eventObserver.postValue(Event.Victory) else -> eventObserver.postValue(Event.ResumeGame) } diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/widget/FixedGridLayoutManager.java b/common/src/main/java/dev/lucasnlm/antimine/common/level/widget/FixedGridLayoutManager.java index 73ad32a5..6bab861d 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/widget/FixedGridLayoutManager.java +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/widget/FixedGridLayoutManager.java @@ -76,7 +76,7 @@ public class FixedGridLayoutManager extends RecyclerView.LayoutManager { @Override public boolean isAutoMeasureEnabled() { - return true; + return false; } /*