Fix scroll
This commit is contained in:
parent
91f6ab4860
commit
808b87145b
3 changed files with 6 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue