|
|
|
@ -32,10 +32,8 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var historyAdapter: HistorySessionRowRepresentableAdapter |
|
|
|
private lateinit var historyAdapter: HistorySessionRowRepresentableAdapter |
|
|
|
// Old |
|
|
|
|
|
|
|
//private lateinit var historyAdapter: HistorySessionRowRepresentableAdapter |
|
|
|
|
|
|
|
private lateinit var realmSessions: RealmResults<Session> |
|
|
|
private lateinit var realmSessions: RealmResults<Session> |
|
|
|
private val sessions: ArrayList<Session> = ArrayList() |
|
|
|
|
|
|
|
private val rows: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
private val rows: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
private var newSessionCreated: Boolean = false |
|
|
|
private var newSessionCreated: Boolean = false |
|
|
|
|
|
|
|
|
|
|
|
@ -82,19 +80,17 @@ class HistoryFragment : PokerAnalyticsFragment(), LiveRowRepresentableDataSource |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
|
|
|
|
|
|
|
|
realmSessions = getRealm().where<Session>().findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
this.realmSessions = getRealm().where<Session>().findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
realmSessions.addChangeListener { t, changeSet -> |
|
|
|
this.realmSessions.addChangeListener { t, changeSet -> |
|
|
|
// if (changeSet.insertions.isNotEmpty() || changeSet.deletions.isNotEmpty()) { |
|
|
|
this.historyAdapter.refreshData() |
|
|
|
historyAdapter.refreshData() |
|
|
|
this.historyAdapter.notifyDataSetChanged() |
|
|
|
// } |
|
|
|
|
|
|
|
historyAdapter.notifyDataSetChanged() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val startedSessions = getRealm().where<Session>().isNotNull("year").isNotNull("month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
val startedSessions = getRealm().where<Session>().isNotNull("year").isNotNull("month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
val pendingSessions = getRealm().where<Session>().isNull("year").isNull("month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
val pendingSessions = getRealm().where<Session>().isNull("year").isNull("month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
val distinctDateSessions = getRealm().where<Session>().distinct("year", "month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
val distinctDateSessions = getRealm().where<Session>().distinct("year", "month").findAll().sort("startDate", Sort.DESCENDING) |
|
|
|
|
|
|
|
|
|
|
|
historyAdapter = HistorySessionRowRepresentableAdapter(this, startedSessions, pendingSessions, distinctDateSessions) |
|
|
|
this.historyAdapter = HistorySessionRowRepresentableAdapter(this, startedSessions, pendingSessions, distinctDateSessions) |
|
|
|
|
|
|
|
|
|
|
|
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
|
|
|
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
|
|
|
recyclerView.apply { |
|
|
|
recyclerView.apply { |
|
|
|
|