Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 3 bugs #27

Merged
merged 3 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MainActivity : AppCompatActivity() {

private var isNightModeOn: Boolean = false
private var selfStart: Boolean = false
private var gamePaused: Boolean = false

private var mediaPlayer: MediaPlayer? = null
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -130,7 +131,8 @@ class MainActivity : AppCompatActivity() {
* Show dialog to restart game
*/
private fun restartGame() {
if (clockState == ClockStates.CLOCK_START) {
if (clockState == ClockStates.CLOCK_START || gamePaused) {
gamePaused = false
val dialog = AlertDialog.Builder(this)
.setMessage("Restart?")
.setPositiveButton(getString(R.string.yesStr)) { _, _ -> // dialog, whichButton are never used
Expand Down Expand Up @@ -158,6 +160,7 @@ class MainActivity : AppCompatActivity() {
pauseTimerTop()
pauseTimerBot()
setColorClocksToNeutral()
gamePaused = true
}

/**
Expand Down Expand Up @@ -246,6 +249,7 @@ class MainActivity : AppCompatActivity() {
* Code to run at Start of Timers
*/
private fun onStartTimer() {
gamePaused = false
clockState = ClockStates.CLOCK_START
mediaPlayer?.start()
pause_button.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ class SettingsActivity : AppCompatActivity() {
val openMainActivity = Intent(this, MainActivity::class.java)
openMainActivity.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT;
startActivityIfNeeded(openMainActivity, 0);
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class SettingsFragment : Fragment() {
setTimePickerSpinners()

start_button.setOnClickListener {
//TODO: check performance
val intent = Intent(activity, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent)
activity?.finish()
}
}

Expand Down