|
|
|
@ -55,6 +55,47 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set fragment data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun setData(isTournament: Boolean, sessionId: String) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
val sessionRealm = realm.findById<Session>(sessionId) |
|
|
|
|
|
|
|
if (sessionRealm != null) { |
|
|
|
|
|
|
|
currentSession = sessionRealm |
|
|
|
|
|
|
|
sessionHasBeenCustomized = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
currentSession = Session.newInstance(realm, isTournament) |
|
|
|
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, null, requireContext()) |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the nearest location around the user |
|
|
|
|
|
|
|
parentActivity?.findNearestLocation { |
|
|
|
|
|
|
|
it?.let { location -> |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
val realmLocation = realm.findById<Location>(location.id) |
|
|
|
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, realmLocation, requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentSession.location = realmLocation |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
updateSessionUI(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sessionHasBeenCustomized = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbar.title = if (currentSession.isTournament()) getString(R.string.tournament) else getString(R.string.cash_game) |
|
|
|
|
|
|
|
collapsingToolbar.title = toolbar.title |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sessionAdapter = RowRepresentableAdapter(currentSession, this) |
|
|
|
|
|
|
|
recyclerView.adapter = sessionAdapter |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateSessionUI(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
override fun onResume() { |
|
|
|
super.onResume() |
|
|
|
super.onResume() |
|
|
|
this.refreshTimer() |
|
|
|
this.refreshTimer() |
|
|
|
@ -308,46 +349,6 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
activity?.finish() |
|
|
|
activity?.finish() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set fragment data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun setData(isTournament: Boolean, sessionId: String) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = getRealm() |
|
|
|
|
|
|
|
val sessionRealm = realm.findById<Session>(sessionId) |
|
|
|
|
|
|
|
if (sessionRealm != null) { |
|
|
|
|
|
|
|
currentSession = sessionRealm |
|
|
|
|
|
|
|
sessionHasBeenCustomized = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
currentSession = Session.newInstance(realm, isTournament) |
|
|
|
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, null, requireContext()) |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the nearest location around the user |
|
|
|
|
|
|
|
parentActivity?.findNearestLocation { |
|
|
|
|
|
|
|
it?.let { location -> |
|
|
|
|
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
val realmLocation = realm.findById<Location>(location.id) |
|
|
|
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, realmLocation, requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentSession.location = realmLocation |
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
updateSessionUI(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sessionHasBeenCustomized = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbar.title = if (currentSession.isTournament()) getString(R.string.tournament) else getString(R.string.cash_game) |
|
|
|
|
|
|
|
collapsingToolbar.title = toolbar.title |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sessionAdapter = RowRepresentableAdapter(currentSession, this) |
|
|
|
|
|
|
|
recyclerView.adapter = sessionAdapter |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateSessionUI(true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Called when the user pressed back on the parent activity |
|
|
|
* Called when the user pressed back on the parent activity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|