cleanup code

feature/top10
Laurent 7 years ago
parent c5b1e1ae56
commit 3ba22318f0
  1. 16
      app/src/main/java/net/pokeranalytics/android/ui/fragment/HistoryFragment.kt

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

Loading…
Cancel
Save