|
|
|
@ -10,13 +10,12 @@ import androidx.core.view.isVisible |
|
|
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator |
|
|
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator |
|
|
|
import com.android.billingclient.api.Purchase |
|
|
|
import com.android.billingclient.api.Purchase |
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
import com.google.android.material.tabs.TabLayout |
|
|
|
import com.google.firebase.crashlytics.FirebaseCrashlytics |
|
|
|
|
|
|
|
import io.realm.RealmModel |
|
|
|
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 |
|
|
|
import kotlinx.android.synthetic.main.fragment_feed.* |
|
|
|
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
|
|
|
import net.pokeranalytics.android.databinding.FragmentFeedBinding |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.model.LiveData |
|
|
|
import net.pokeranalytics.android.model.LiveData |
|
|
|
import net.pokeranalytics.android.model.interfaces.Editable |
|
|
|
import net.pokeranalytics.android.model.interfaces.Editable |
|
|
|
@ -105,6 +104,9 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var _binding: FragmentFeedBinding? = null |
|
|
|
|
|
|
|
private val binding get() = _binding!! |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
AppGuard.registerListener(this) |
|
|
|
AppGuard.registerListener(this) |
|
|
|
@ -114,9 +116,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
inflater: LayoutInflater, |
|
|
|
inflater: LayoutInflater, |
|
|
|
container: ViewGroup?, |
|
|
|
container: ViewGroup?, |
|
|
|
savedInstanceState: Bundle? |
|
|
|
savedInstanceState: Bundle? |
|
|
|
): View? { |
|
|
|
): View { |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
return inflater.inflate(R.layout.fragment_feed, container, false) |
|
|
|
_binding = FragmentFeedBinding.inflate(inflater, container, false) |
|
|
|
|
|
|
|
return binding.root |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) { |
|
|
|
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) { |
|
|
|
@ -219,6 +222,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
override fun onDestroyView() { |
|
|
|
override fun onDestroyView() { |
|
|
|
super.onDestroyView() |
|
|
|
super.onDestroyView() |
|
|
|
realmTransactions.removeAllChangeListeners() |
|
|
|
realmTransactions.removeAllChangeListeners() |
|
|
|
|
|
|
|
_binding = null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { |
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, tag: Int) { |
|
|
|
@ -250,43 +254,43 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
|
|
this.sessionAdapter = FeedSessionRowRepresentableAdapter(getRealm(), this) |
|
|
|
this.sessionAdapter = FeedSessionRowRepresentableAdapter(getRealm(), this) |
|
|
|
|
|
|
|
|
|
|
|
registerForContextMenu(this.menuRecyclerView) |
|
|
|
registerForContextMenu(binding.menuRecyclerView) |
|
|
|
|
|
|
|
|
|
|
|
val messageToShow: Preferences.FeedMessage? = |
|
|
|
val messageToShow: Preferences.FeedMessage? = |
|
|
|
Preferences.feedMessageToShow(requireContext()) |
|
|
|
Preferences.feedMessageToShow(requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
if (messageToShow != null) { |
|
|
|
if (messageToShow != null) { |
|
|
|
messageBox.isVisible = true |
|
|
|
binding.messageBox.isVisible = true |
|
|
|
message.text = getString(messageToShow.resId) |
|
|
|
binding.message.text = getString(messageToShow.resId) |
|
|
|
|
|
|
|
|
|
|
|
messageToShow.actionResId?.let { |
|
|
|
messageToShow.actionResId?.let { |
|
|
|
messageBoxAction.text = requireContext().getString(it) |
|
|
|
binding.messageBoxAction.text = requireContext().getString(it) |
|
|
|
messageToShow.action(requireContext())?.let { action -> |
|
|
|
messageToShow.action(requireContext())?.let { action -> |
|
|
|
messageBoxAction.setOnClickListener { view -> |
|
|
|
binding.messageBoxAction.setOnClickListener { view -> |
|
|
|
action.invoke(view) |
|
|
|
action.invoke(view) |
|
|
|
hideMessageBox(messageToShow) |
|
|
|
hideMessageBox(messageToShow) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
messageBoxAction.visibility = View.GONE |
|
|
|
binding.messageBoxAction.visibility = View.GONE |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
messageBoxDismiss.text = requireContext().getString(messageToShow.dismissResId) |
|
|
|
binding.messageBoxDismiss.text = requireContext().getString(messageToShow.dismissResId) |
|
|
|
messageBoxDismiss.setOnClickListener { |
|
|
|
binding.messageBoxDismiss.setOnClickListener { |
|
|
|
hideMessageBox(messageToShow) |
|
|
|
hideMessageBox(messageToShow) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
messageBox.isVisible = false |
|
|
|
binding.messageBox.isVisible = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
|
|
|
val viewManager = SmoothScrollLinearLayoutManager(requireContext()) |
|
|
|
menuRecyclerView.apply { |
|
|
|
binding.menuRecyclerView.apply { |
|
|
|
setHasFixedSize(true) |
|
|
|
setHasFixedSize(true) |
|
|
|
layoutManager = viewManager |
|
|
|
layoutManager = viewManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add button |
|
|
|
// Add button |
|
|
|
addButton.setOnClickListener { |
|
|
|
binding.addButton.setOnClickListener { |
|
|
|
activity?.let { |
|
|
|
activity?.let { |
|
|
|
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(it) |
|
|
|
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(it) |
|
|
|
val intent = Intent(requireContext(), NewDataMenuActivity::class.java) |
|
|
|
val intent = Intent(requireContext(), NewDataMenuActivity::class.java) |
|
|
|
@ -295,7 +299,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tabs |
|
|
|
// Tabs |
|
|
|
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
binding.tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
override fun onTabSelected(tab: TabLayout.Tab) { |
|
|
|
override fun onTabSelected(tab: TabLayout.Tab) { |
|
|
|
when (tab.position) { |
|
|
|
when (tab.position) { |
|
|
|
Tab.SESSIONS.ordinal -> { |
|
|
|
Tab.SESSIONS.ordinal -> { |
|
|
|
@ -318,7 +322,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
this.subscribe.setOnClickListener { |
|
|
|
binding.subscribe.setOnClickListener { |
|
|
|
if (!AppGuard.isProUser) { |
|
|
|
if (!AppGuard.isProUser) { |
|
|
|
BillingActivity.newInstanceForResult(this, false) |
|
|
|
BillingActivity.newInstanceForResult(this, false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
@ -330,15 +334,16 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun showSubscriptionButton() { |
|
|
|
private fun showSubscriptionButton() { |
|
|
|
this.subscribe.isVisible = !AppGuard.isProUser |
|
|
|
this.binding.subscribe.isVisible = !AppGuard.isProUser |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun hideMessageBox(message: Preferences.FeedMessage) { |
|
|
|
private fun hideMessageBox(message: Preferences.FeedMessage) { |
|
|
|
Preferences.setStopShowingMessage(message, requireContext()) |
|
|
|
Preferences.setStopShowingMessage(message, requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val messageBox = binding.messageBox |
|
|
|
messageBox.animate().translationY(messageBox.height.toFloat()) |
|
|
|
messageBox.animate().translationY(messageBox.height.toFloat()) |
|
|
|
.setInterpolator(FastOutSlowInInterpolator()) |
|
|
|
.setInterpolator(FastOutSlowInInterpolator()) |
|
|
|
.withEndAction { messageBox?.isVisible = false } |
|
|
|
.withEndAction { messageBox.isVisible = false } |
|
|
|
.start() |
|
|
|
.start() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -553,7 +558,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
|
|
private fun selectTab(tab: Tab) { |
|
|
|
private fun selectTab(tab: Tab) { |
|
|
|
this.currentTab = tab |
|
|
|
this.currentTab = tab |
|
|
|
this.tabs.getTabAt(tab.ordinal)?.select() |
|
|
|
this.binding.tabs.getTabAt(tab.ordinal)?.select() |
|
|
|
setAdapter() |
|
|
|
setAdapter() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -564,9 +569,9 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis |
|
|
|
|
|
|
|
|
|
|
|
private fun setAdapter() { |
|
|
|
private fun setAdapter() { |
|
|
|
when (this.currentTab) { |
|
|
|
when (this.currentTab) { |
|
|
|
Tab.SESSIONS -> menuRecyclerView.adapter = sessionAdapter |
|
|
|
Tab.SESSIONS -> binding.menuRecyclerView.adapter = sessionAdapter |
|
|
|
Tab.TRANSACTIONS -> menuRecyclerView.adapter = transactionAdapter |
|
|
|
Tab.TRANSACTIONS -> binding.menuRecyclerView.adapter = transactionAdapter |
|
|
|
Tab.HAND_HISTORY -> menuRecyclerView.adapter = handHistoryAdapter |
|
|
|
Tab.HAND_HISTORY -> binding.menuRecyclerView.adapter = handHistoryAdapter |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|