|
|
|
|
@ -12,6 +12,7 @@ import com.android.billingclient.api.Purchase |
|
|
|
|
import com.google.android.material.badge.BadgeDrawable |
|
|
|
|
import com.google.android.material.badge.BadgeUtils |
|
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import io.realm.RealmModel |
|
|
|
|
import io.realm.RealmResults |
|
|
|
|
import io.realm.Sort |
|
|
|
|
@ -30,6 +31,7 @@ import net.pokeranalytics.android.ui.activity.components.RequestCode |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.openUrl |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.FilterableFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.RealmAsyncListener |
|
|
|
|
import net.pokeranalytics.android.ui.modules.data.EditableDataActivity |
|
|
|
|
import net.pokeranalytics.android.ui.modules.datalist.DataListActivity |
|
|
|
|
import net.pokeranalytics.android.ui.modules.filter.FilterActivityRequestCode |
|
|
|
|
@ -47,7 +49,7 @@ import net.pokeranalytics.android.util.extensions.count |
|
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseListener { |
|
|
|
|
class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseListener, RealmAsyncListener { |
|
|
|
|
|
|
|
|
|
private enum class Tab { |
|
|
|
|
SESSIONS, |
|
|
|
|
@ -84,14 +86,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
private var badgeDrawable: BadgeDrawable? = null |
|
|
|
|
|
|
|
|
|
override val observedEntities: List<Class<out RealmModel>> = |
|
|
|
|
listOf(Session::class.java, Transaction::class.java, HandHistory::class.java) |
|
|
|
|
|
|
|
|
|
override fun entitiesChanged( |
|
|
|
|
clazz: Class<out RealmModel>, |
|
|
|
|
results: RealmResults<out RealmModel> |
|
|
|
|
) { |
|
|
|
|
super.entitiesChanged(clazz, results) |
|
|
|
|
override fun asyncListenedEntityChange(realm: Realm, clazz: Class<out RealmModel>) { |
|
|
|
|
|
|
|
|
|
when (clazz.kotlin) { |
|
|
|
|
Session::class -> { |
|
|
|
|
@ -107,7 +102,6 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
this.handHistoryAdapter.notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var _binding: FragmentFeedBinding? = null |
|
|
|
|
@ -142,11 +136,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
when (item.itemId) { |
|
|
|
|
R.id.duplicate -> { |
|
|
|
|
val session = this.sessionAdapter.sessionForPosition(menuPosition) |
|
|
|
|
if (session != null) { |
|
|
|
|
createNewSession(true, sessionId = session.id, duplicate = true) |
|
|
|
|
} else { |
|
|
|
|
throw PAIllegalStateException("Session not found for duplicate at position: $menuPosition") |
|
|
|
|
} |
|
|
|
|
createNewSession(true, sessionId = session.id, duplicate = true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -158,6 +148,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
AppGuard.registerListener(this) |
|
|
|
|
|
|
|
|
|
addRealmChangeListener(this, Session::class.java) |
|
|
|
|
addRealmChangeListener(this, Transaction::class.java) |
|
|
|
|
addRealmChangeListener(this, HandHistory::class.java) |
|
|
|
|
|
|
|
|
|
initUI() |
|
|
|
|
initData() |
|
|
|
|
} |
|
|
|
|
@ -482,9 +476,8 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
// gets the first session of the adapter - the last created - to preconfigure the HH |
|
|
|
|
if (this.sessionAdapter.itemCount > 0) { |
|
|
|
|
this.sessionAdapter.sessionForPosition(0)?.let { session -> |
|
|
|
|
HandHistoryActivity.newInstance(this, session, false) |
|
|
|
|
} ?: throw PAIllegalStateException("Cannot happen") |
|
|
|
|
val session = this.sessionAdapter.sessionForPosition(0) |
|
|
|
|
HandHistoryActivity.newInstance(this, session, false) |
|
|
|
|
} else { |
|
|
|
|
HandHistoryActivity.newInstance(this) |
|
|
|
|
} |
|
|
|
|
|