-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
368 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/GameSolvedFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.piepmeyer.gauguin.ui.main | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
import org.piepmeyer.gauguin.R | ||
import org.piepmeyer.gauguin.Utils | ||
import org.piepmeyer.gauguin.databinding.FragmentMainGameSolvedBinding | ||
import org.piepmeyer.gauguin.game.Game | ||
import org.piepmeyer.gauguin.game.GameSolvedListener | ||
import org.piepmeyer.gauguin.game.GridCreationListener | ||
import org.piepmeyer.gauguin.preferences.StatisticsManager | ||
import org.piepmeyer.gauguin.preferences.TypeOfSolved | ||
import org.piepmeyer.gauguin.ui.StatisticsActivity | ||
|
||
class GameSolvedFragment : | ||
Fragment(R.layout.fragment_main_game_solved), | ||
KoinComponent, | ||
GameSolvedListener, | ||
GridCreationListener { | ||
private val game: Game by inject() | ||
private val statisticsManager: StatisticsManager by inject() | ||
|
||
private lateinit var binding: FragmentMainGameSolvedBinding | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
parent: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
binding = FragmentMainGameSolvedBinding.inflate(inflater, parent, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
binding.showStatisticsButton.setOnClickListener { | ||
requireActivity().startActivity( | ||
Intent( | ||
requireActivity(), | ||
StatisticsActivity::class.java, | ||
), | ||
) | ||
} | ||
|
||
game.addGameSolvedHandler(this) | ||
game.addGridCreationListener(this) | ||
} | ||
|
||
override fun puzzleSolved(troughReveal: Boolean) { | ||
binding.detailsIcon | ||
|
||
if (!troughReveal) { | ||
val iconAndText = | ||
when (statisticsManager.typeOfSolved(game.grid)) { | ||
TypeOfSolved.FirstGame -> Pair(R.drawable.trophy_variant_outline, "Erstes Spiel gewonnen!") | ||
TypeOfSolved.FirstGameOfKind -> Pair(R.drawable.trophy_variant_outline, "Erstes Spiel dieser Art gewonnen!") | ||
TypeOfSolved.BestTimeOfKind -> Pair(R.drawable.podium_gold, "Neue Bestzeit!") | ||
TypeOfSolved.Regular -> | ||
Pair( | ||
null, | ||
"Bestehende Bestzeit: " + Utils.displayableGameDuration(statisticsManager.getBestTime(game.grid)), | ||
) | ||
} | ||
|
||
if (iconAndText.first != null) { | ||
binding.detailsIcon.setImageResource(iconAndText.first!!) | ||
} else { | ||
binding.detailsIcon.visibility = View.INVISIBLE | ||
} | ||
|
||
binding.detailsText.text = iconAndText.second | ||
} else { | ||
binding.detailsIcon.visibility = View.INVISIBLE | ||
binding.detailsText.visibility = View.INVISIBLE | ||
} | ||
|
||
binding.gameSolvedCardView.visibility = View.VISIBLE | ||
} | ||
|
||
override fun freshGridWasCreated() { | ||
binding.gameSolvedCardView.visibility = View.GONE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- drawable/flag_checkered.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M14.4,6H20V16H13L12.6,14H7V21H5V4H14L14.4,6M14,14H16V12H18V10H16V8H14V10L13,8V6H11V8H9V6H7V8H9V10H7V12H9V10H11V12H13V10L14,12V14M11,10V8H13V10H11M14,10H16V12H14V10Z" /></vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- drawable/human_handsup.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M5,1C5,3.7 6.56,6.16 9,7.32V22H11V15H13V22H15V7.31C17.44,6.16 19,3.7 19,1H17A5,5 0 0,1 12,6A5,5 0 0,1 7,1M12,1C10.89,1 10,1.89 10,3C10,4.11 10.89,5 12,5C13.11,5 14,4.11 14,3C14,1.89 13.11,1 12,1Z" /></vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- drawable/podium_gold.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,7.09L14.45,8.58L13.8,5.77L16,3.89L13.11,3.64L12,1L10.87,3.64L8,3.89L10.18,5.77L9.5,8.58L12,7.09M15,23H9V10H15V23M1,17V23H7V17H1M5,21H3V19H5V21M17,13V23H23V13H17M21,21H19V15H21V21Z" /></vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- drawable/trophy_variant_outline.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M17 4V2H7V4H2V11C2 12.1 2.9 13 4 13H7.1C7.5 14.96 9.04 16.5 11 16.9V19.08C8 19.54 8 22 8 22H16C16 22 16 19.54 13 19.08V16.9C14.96 16.5 16.5 14.96 16.9 13H20C21.1 13 22 12.1 22 11V4H17M4 11V6H7V11L4 11M15 12C15 13.65 13.65 15 12 15S9 13.65 9 12V4H15V12M20 11L17 11V6H20L20 11Z" /></vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.