Fixes issue where pending sessions were displayed twice

dev
Laurent 7 years ago
parent c598211c15
commit dc4635f9e8
  1. 35
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt

@ -116,7 +116,12 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
is Transaction -> { is Transaction -> {
selectedTransaction = row selectedTransaction = row
selectedTransactionPosition = position selectedTransactionPosition = position
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, row.id, REQUEST_CODE_TRANSACTION_DETAILS) EditableDataActivity.newInstanceForResult(
this,
LiveData.TRANSACTION,
row.id,
REQUEST_CODE_TRANSACTION_DETAILS
)
} }
} }
} }
@ -195,17 +200,24 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
} }
// Sessions // Sessions
this.realmSessions = sessionFilter?.results() ?: run { getRealm().where<Session>().findAll() } this.realmSessions = sessionFilter?.results() ?: run { getRealm().where<Session>().isNotNull("startDate").findAll() }
this.realmSessions = this.realmSessions.sort("startDate", Sort.DESCENDING) this.realmSessions = this.realmSessions.sort("startDate", Sort.DESCENDING)
this.realmSessions.addChangeListener { _, _ -> this.realmSessions.addChangeListener { _, _ ->
this.feedSessionAdapter.refreshData() this.feedSessionAdapter.refreshData()
this.feedSessionAdapter.notifyDataSetChanged() this.feedSessionAdapter.notifyDataSetChanged()
} }
val pendingSessions = sessionFilter?.let { getRealm().where<Session>().alwaysFalse().findAll() } ?: run { getRealm().where<Session>().isNull("year").isNull("month").findAll().sort("startDate", Sort.DESCENDING) } val pendingSessions = sessionFilter?.let {
var distinctDateSessions = sessionFilter?.results("year", "month") ?: run { getRealm().where<Session>().distinct("year", "month").findAll() } getRealm().where<Session>().alwaysFalse().findAll()
} ?: run {
getRealm().where<Session>().isNull("year").isNull("month").findAll().sort("startDate", Sort.DESCENDING)
}
var distinctDateSessions = sessionFilter?.results("year", "month") ?: run {
getRealm().where<Session>().distinct("year", "month").findAll()
}
distinctDateSessions = distinctDateSessions.sort("startDate", Sort.DESCENDING) distinctDateSessions = distinctDateSessions.sort("startDate", Sort.DESCENDING)
this.feedSessionAdapter = FeedSessionRowRepresentableAdapter(this, realmSessions, pendingSessions, distinctDateSessions) this.feedSessionAdapter =
FeedSessionRowRepresentableAdapter(this, realmSessions, pendingSessions, distinctDateSessions)
} }
private fun loadTransactions(filter: Filter? = null) { private fun loadTransactions(filter: Filter? = null) {
@ -225,9 +237,12 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
this.feedTransactionAdapter.notifyDataSetChanged() this.feedTransactionAdapter.notifyDataSetChanged()
} }
var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run { getRealm().where<Transaction>().distinct("year", "month").findAll() } var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run {
getRealm().where<Transaction>().distinct("year", "month").findAll()
}
distinctDateTransactions = distinctDateTransactions.sort("date", Sort.DESCENDING) distinctDateTransactions = distinctDateTransactions.sort("date", Sort.DESCENDING)
this.feedTransactionAdapter = FeedTransactionRowRepresentableAdapter(this, realmTransactions, distinctDateTransactions) this.feedTransactionAdapter =
FeedTransactionRowRepresentableAdapter(this, realmTransactions, distinctDateTransactions)
} }
@ -280,7 +295,11 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
* Show end of beta message * Show end of beta message
*/ */
private fun showEndOfBetaMessage() { private fun showEndOfBetaMessage() {
Toast.makeText(context, "Beta has ended. Thanks a lot for your participation! Please update with the Google Play version to continue using the app", Toast.LENGTH_LONG).show() Toast.makeText(
context,
"Beta has ended. Thanks a lot for your participation! Please update with the Google Play version to continue using the app",
Toast.LENGTH_LONG
).show()
} }

Loading…
Cancel
Save