|
|
|
|
@ -13,6 +13,7 @@ import kotlinx.android.synthetic.main.fragment_session.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.model.extensions.SessionState |
|
|
|
|
import net.pokeranalytics.android.model.extensions.getState |
|
|
|
|
import net.pokeranalytics.android.model.realm.Location |
|
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
import net.pokeranalytics.android.model.utils.FavoriteSessionFinder |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
|
@ -31,8 +32,10 @@ import java.util.* |
|
|
|
|
|
|
|
|
|
class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, BottomSheetDelegate { |
|
|
|
|
|
|
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
private lateinit var currentSession: Session |
|
|
|
|
private lateinit var sessionAdapter: RowRepresentableAdapter |
|
|
|
|
|
|
|
|
|
private var sessionMenu: Menu? = null |
|
|
|
|
private val oldRows: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
|
private val handler: Handler = Handler() |
|
|
|
|
@ -115,13 +118,13 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Bott |
|
|
|
|
*/ |
|
|
|
|
private fun initUI() { |
|
|
|
|
|
|
|
|
|
val activity = activity as PokerAnalyticsActivity |
|
|
|
|
parentActivity = activity as PokerAnalyticsActivity |
|
|
|
|
|
|
|
|
|
// Avoid a bug during setting the title |
|
|
|
|
toolbar.title = "" |
|
|
|
|
|
|
|
|
|
activity.setSupportActionBar(toolbar) |
|
|
|
|
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
|
parentActivity.setSupportActionBar(toolbar) |
|
|
|
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
|
setHasOptionsMenu(true) |
|
|
|
|
|
|
|
|
|
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
|
|
|
|
@ -280,9 +283,24 @@ class SessionFragment : PokerAnalyticsFragment(), RowRepresentableDelegate, Bott |
|
|
|
|
currentSession = Session.newInstance(realm, isTournament) |
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, null, requireContext()) |
|
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
// Find the nearest location around the user |
|
|
|
|
parentActivity.findNearestLocation { location -> |
|
|
|
|
location?.let { |
|
|
|
|
realm.beginTransaction() |
|
|
|
|
val realmLocation = realm.where<Location>().equalTo("id", it.id).findFirst() |
|
|
|
|
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, realmLocation, requireContext()) |
|
|
|
|
|
|
|
|
|
currentSession.location = realmLocation |
|
|
|
|
realm.commitTransaction() |
|
|
|
|
updateSessionUI() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbar.title = if (currentSession.isTournament()) getString(R.string.tournament) else getString(R.string.cash_game) |
|
|
|
|
toolbar.title = |
|
|
|
|
if (currentSession.isTournament()) getString(R.string.tournament) else getString(R.string.cash_game) |
|
|
|
|
|
|
|
|
|
sessionAdapter = RowRepresentableAdapter(currentSession, this) |
|
|
|
|
recyclerView.adapter = sessionAdapter |
|
|
|
|
|