|
|
|
|
@ -48,7 +48,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
private lateinit var model: SessionViewModel |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
const val TIMER_DELAY = 60000L |
|
|
|
|
const val TIMER_DELAY = 5000L |
|
|
|
|
const val REQUEST_CODE_NEW_CUSTOM_FIELD = 1000 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
private var sessionHasBeenUserCustomized = false |
|
|
|
|
private val handler: Handler = Handler() |
|
|
|
|
|
|
|
|
|
private val refreshTimer: Runnable = object : Runnable { |
|
|
|
|
private val timer: Runnable = object : Runnable { |
|
|
|
|
override fun run() { |
|
|
|
|
refreshTimer() |
|
|
|
|
handler.postDelayed(this, |
|
|
|
|
@ -149,7 +149,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
|
|
|
|
|
override fun onPause() { |
|
|
|
|
super.onPause() |
|
|
|
|
handler.removeCallbacksAndMessages(null) |
|
|
|
|
this.stopTimer() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { |
|
|
|
|
@ -297,7 +297,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f) |
|
|
|
|
.setDuration(animationDuration) |
|
|
|
|
.setInterpolator(OvershootInterpolator()).start() |
|
|
|
|
handler.postDelayed(refreshTimer, Date().getNextMinuteInMilliseconds()) |
|
|
|
|
handler.postDelayed(timer, Date().getNextMinuteInMilliseconds()) |
|
|
|
|
} |
|
|
|
|
SessionState.STARTED -> { |
|
|
|
|
sessionMenu?.findItem(R.id.restart)?.isVisible = true |
|
|
|
|
@ -306,7 +306,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
floatingActionButton.animate().scaleX(1f).scaleY(1f).alpha(1f) |
|
|
|
|
.setDuration(animationDuration) |
|
|
|
|
.setInterpolator(OvershootInterpolator()).start() |
|
|
|
|
handler.postDelayed(refreshTimer, Date().getNextMinuteInMilliseconds()) |
|
|
|
|
handler.postDelayed(timer, Date().getNextMinuteInMilliseconds()) |
|
|
|
|
} |
|
|
|
|
SessionState.PAUSED -> { |
|
|
|
|
sessionMenu?.findItem(R.id.restart)?.isVisible = true |
|
|
|
|
@ -468,11 +468,15 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
*/ |
|
|
|
|
private fun deleteSession() { |
|
|
|
|
|
|
|
|
|
this.stopTimer() |
|
|
|
|
this.currentSession.cancelStopNotification(requireContext()) |
|
|
|
|
this.currentSession.bankroll?.id?.let { bankrollId -> |
|
|
|
|
|
|
|
|
|
val bankrollId = this.currentSession.bankroll?.id |
|
|
|
|
|
|
|
|
|
this.currentSession.delete() |
|
|
|
|
bankrollId?.let { |
|
|
|
|
BankrollReportManager.notifyBankrollReportImpact(bankrollId) |
|
|
|
|
} |
|
|
|
|
this.currentSession.delete() |
|
|
|
|
activity?.finish() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -660,4 +664,8 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr |
|
|
|
|
this.updateRowRepresentation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun stopTimer() { |
|
|
|
|
handler.removeCallbacksAndMessages(null) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |