mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 20:59:00 +00:00
fix banner flickering
This commit is contained in:
parent
337225cc99
commit
2b02a07c34
5 changed files with 24 additions and 20 deletions
|
|
@ -75,7 +75,7 @@ class PurchaseHandler(
|
|||
purchase.products.firstOrNull()
|
||||
)
|
||||
) {
|
||||
if ((plan.additionalData?.data?.orderId == purchase.orderId && ((plan.dateTerminated != null) == purchase.isAutoRenewing)) || mostRecentSub?.orderId != purchase.orderId) {
|
||||
if (((plan.dateTerminated != null) == purchase.isAutoRenewing) || mostRecentSub?.orderId != purchase.orderId) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +123,8 @@ class PurchaseHandler(
|
|||
fun startListening() {
|
||||
if (billingClient.connectionState == BillingClient.ConnectionState.CONNECTING
|
||||
|| billingClient.connectionState == BillingClient.ConnectionState.CONNECTED
|
||||
|| billingClientState == BillingClientState.UNAVAILABLE) {
|
||||
|| billingClientState == BillingClientState.UNAVAILABLE
|
||||
) {
|
||||
// Don't connect again if it's already connected
|
||||
return
|
||||
}
|
||||
|
|
@ -209,8 +210,8 @@ class PurchaseHandler(
|
|||
billingClientState.canMaybePurchase && billingClient.isReady
|
||||
}
|
||||
val params = QueryProductDetailsParams.newBuilder().setProductList(skus.map {
|
||||
Product.newBuilder().setProductId(it).setProductType(type).build()
|
||||
}).build()
|
||||
Product.newBuilder().setProductId(it).setProductType(type).build()
|
||||
}).build()
|
||||
val skuDetailsResult = withContext(Dispatchers.IO) {
|
||||
billingClient.queryProductDetails(params)
|
||||
}
|
||||
|
|
@ -230,11 +231,11 @@ class PurchaseHandler(
|
|||
}
|
||||
val flowParams =
|
||||
BillingFlowParams.newBuilder().setProductDetailsParamsList(listOf(skuDetails).map {
|
||||
BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(skuDetails).setOfferToken(
|
||||
skuDetails.subscriptionOfferDetails?.first()?.offerToken ?: ""
|
||||
).build()
|
||||
}).build()
|
||||
BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
.setProductDetails(skuDetails).setOfferToken(
|
||||
skuDetails.subscriptionOfferDetails?.first()?.offerToken ?: ""
|
||||
).build()
|
||||
}).build()
|
||||
billingClient.launchBillingFlow(activity, flowParams)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.habitrpg.android.habitica.ui.views.promo.PromoMenuViewHolder
|
|||
import com.habitrpg.android.habitica.ui.views.promo.SubscriptionBuyGemsPromoView
|
||||
import com.habitrpg.android.habitica.ui.views.promo.SubscriptionBuyGemsPromoViewHolder
|
||||
import com.habitrpg.common.habitica.extensions.dpToPx
|
||||
import java.util.Date
|
||||
|
||||
class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
|
|
@ -64,7 +65,8 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int) : Recycl
|
|||
fun updateItem(item: HabiticaDrawerItem) {
|
||||
val position = getItemPosition(item.identifier)
|
||||
items[position] = item
|
||||
notifyDataSetChanged()
|
||||
val visiblePosition = getVisibleItemPosition(item.identifier)
|
||||
notifyItemChanged(visiblePosition)
|
||||
}
|
||||
|
||||
fun updateItems(newItems: List<HabiticaDrawerItem>) {
|
||||
|
|
@ -97,6 +99,9 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int) : Recycl
|
|||
getItemViewType(position) == 6 -> {
|
||||
currentEvent?.end?.let {
|
||||
(holder.itemView as? ComposeView)?.setContent {
|
||||
if (it.before(Date())) {
|
||||
return@setContent
|
||||
}
|
||||
BirthdayBanner(it)
|
||||
}
|
||||
}
|
||||
|
|
@ -106,6 +111,7 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int) : Recycl
|
|||
|
||||
private fun getItem(position: Int) = items.filter { it.isVisible }[position]
|
||||
|
||||
|
||||
override fun getItemCount(): Int = items.count { it.isVisible }
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.habitrpg.android.habitica.ui.views
|
|||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateIntAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
|
|
@ -55,10 +55,10 @@ fun LabeledBar(
|
|||
) {
|
||||
val cleanedMaxValue = java.lang.Double.max(1.0, maxValue)
|
||||
|
||||
val animatedValue = if (animated) animateIntAsState(
|
||||
targetValue = value.toInt(),
|
||||
val animatedValue = if (animated) animateFloatAsState(
|
||||
targetValue = value.toFloat(),
|
||||
animationSpec = spring()
|
||||
).value else value.toInt()
|
||||
).value else value.toFloat()
|
||||
val formatter = NumberFormat.getNumberInstance()
|
||||
formatter.minimumFractionDigits = 0
|
||||
formatter.maximumFractionDigits = 2
|
||||
|
|
@ -93,7 +93,7 @@ fun LabeledBar(
|
|||
if (!disabled) {
|
||||
val currentValueText = if (abbreviateValue) NumberAbbreviator.abbreviate(
|
||||
LocalContext.current,
|
||||
animatedValue.toFloat(),
|
||||
animatedValue,
|
||||
0
|
||||
) else formatter.format(animatedValue)
|
||||
val maxValueText = if (abbreviateMax) NumberAbbreviator.abbreviate(
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ import kotlin.time.Duration.Companion.seconds
|
|||
|
||||
@Composable
|
||||
fun BirthdayBanner(endDate: Date, modifier: Modifier = Modifier) {
|
||||
if (endDate.before(Date())) {
|
||||
return
|
||||
}
|
||||
Column(
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.1.4
|
||||
CODE=5261
|
||||
NAME=4.1.5
|
||||
CODE=5271
|
||||
Loading…
Reference in a new issue