mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
Improve subscription loading. Fixes #1255
This commit is contained in:
parent
c47d2c5c96
commit
630125a29c
2 changed files with 25 additions and 8 deletions
|
|
@ -1,11 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/scrollbarThumb"
|
||||
android:scrollbars="vertical"
|
||||
|
|
@ -370,4 +374,4 @@
|
|||
android:drawablePadding="@dimen/spacing_medium"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView></androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
|
@ -52,14 +52,13 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
fetchUser(null)
|
||||
binding = FragmentSubscriptionBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun fetchUser(event: UserSubscribedEvent?) {
|
||||
compositeSubscription.add(userRepository.retrieveUser(withTasks = false, forced = true).subscribe(Consumer { this.setUser(it) }, RxErrorHandler.handleEmptyError()))
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
@ -79,7 +78,9 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
|
|||
|
||||
binding.subscribeButton.setOnClickListener { subscribeUser() }
|
||||
|
||||
binding.giftSubscriptionContainer?.isVisible = appConfigManager.enableGiftOneGetOne()
|
||||
binding.giftSubscriptionContainer.isVisible = appConfigManager.enableGiftOneGetOne()
|
||||
|
||||
binding.refreshLayout.setOnRefreshListener { refresh() }
|
||||
|
||||
if (appConfigManager.useNewMysteryBenefits()) {
|
||||
compositeSubscription.add(inventoryRepository.getLatestMysteryItem().subscribe(Consumer {
|
||||
|
|
@ -89,12 +90,24 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
|
|||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
refresh();
|
||||
}
|
||||
|
||||
private fun refresh() {
|
||||
compositeSubscription.add(userRepository.retrieveUser(withTasks = false, forced = true).subscribe(Consumer {
|
||||
this.setUser(it)
|
||||
binding.refreshLayout.isRefreshing = false
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun injectFragment(component: UserComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
||||
override fun setupCheckout() {
|
||||
purchaseHandler?.getAllSubscriptionProducts {subscriptions ->
|
||||
purchaseHandler?.getAllSubscriptionProducts { subscriptions ->
|
||||
this.skus = subscriptions.skus
|
||||
for (sku in subscriptions.skus) {
|
||||
updateButtonLabel(sku, sku.price, subscriptions)
|
||||
|
|
|
|||
Loading…
Reference in a new issue