|
|
|
@ -11,6 +11,7 @@ import androidx.core.app.ActivityOptionsCompat |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator |
|
|
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator |
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
|
|
|
|
import io.realm.RealmModel |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.RealmResults |
|
|
|
import io.realm.Sort |
|
|
|
import io.realm.Sort |
|
|
|
import io.realm.kotlin.where |
|
|
|
import io.realm.kotlin.where |
|
|
|
@ -61,6 +62,24 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
private var selectedTransaction: Transaction? = null |
|
|
|
private var selectedTransaction: Transaction? = null |
|
|
|
private var selectedTransactionPosition: Int = -1 |
|
|
|
private var selectedTransactionPosition: Int = -1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val observedEntities: List<Class<out RealmModel>> = listOf(Session::class.java, Transaction::class.java) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun entitiesChanged(clazz: Class<out RealmModel>) { |
|
|
|
|
|
|
|
super.entitiesChanged(clazz) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when (clazz.kotlin) { |
|
|
|
|
|
|
|
Session::class -> { |
|
|
|
|
|
|
|
this.feedSessionAdapter.refreshData() |
|
|
|
|
|
|
|
this.feedSessionAdapter.notifyDataSetChanged() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Transaction::class -> { |
|
|
|
|
|
|
|
this.feedTransactionAdapter.refreshData() |
|
|
|
|
|
|
|
this.feedTransactionAdapter.notifyDataSetChanged() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
return inflater.inflate(R.layout.fragment_feed, container, false) |
|
|
|
return inflater.inflate(R.layout.fragment_feed, container, false) |
|
|
|
@ -200,12 +219,9 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sessions |
|
|
|
// Sessions |
|
|
|
this.realmSessions = sessionFilter?.results() ?: run { getRealm().where<Session>().isNotNull("startDate").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.feedSessionAdapter.refreshData() |
|
|
|
|
|
|
|
this.feedSessionAdapter.notifyDataSetChanged() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val pendingSessions = sessionFilter?.let { |
|
|
|
val pendingSessions = sessionFilter?.let { |
|
|
|
getRealm().where<Session>().alwaysFalse().findAll() |
|
|
|
getRealm().where<Session>().alwaysFalse().findAll() |
|
|
|
@ -232,10 +248,6 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate { |
|
|
|
// Transactions |
|
|
|
// Transactions |
|
|
|
this.realmTransactions = transactionFilter?.results() ?: run { getRealm().where<Transaction>().findAll() } |
|
|
|
this.realmTransactions = transactionFilter?.results() ?: run { getRealm().where<Transaction>().findAll() } |
|
|
|
this.realmTransactions = this.realmTransactions.sort("date", Sort.DESCENDING) |
|
|
|
this.realmTransactions = this.realmTransactions.sort("date", Sort.DESCENDING) |
|
|
|
this.realmTransactions.addChangeListener { _, _ -> |
|
|
|
|
|
|
|
this.feedTransactionAdapter.refreshData() |
|
|
|
|
|
|
|
this.feedTransactionAdapter.notifyDataSetChanged() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run { |
|
|
|
var distinctDateTransactions = transactionFilter?.results("year", "month") ?: run { |
|
|
|
getRealm().where<Transaction>().distinct("year", "month").findAll() |
|
|
|
getRealm().where<Transaction>().distinct("year", "month").findAll() |
|
|
|
|