Skip to content

Commit

Permalink
fix(study set): sửa lỗi tính progress ở các màn hình học
Browse files Browse the repository at this point in the history
- tắt loading khi lấy quảng cáo lỗi
  • Loading branch information
nqmgaming committed Dec 17, 2024
1 parent 50b5e2c commit 47f719f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ fun Explore(
isGettingAds = true
AdsUtil.rewardedInterstitialAd(
context,
) {
onEarnCoins()
isGettingAds = false
}
onAdLoadFailedToLoad = {
isGettingAds = false
},
onAdWatched = {
onEarnCoins()
isGettingAds = false
}
)
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ fun LearnByQuiz(
.padding(innerPadding)
) {
val currentProgress by animateFloatAsState(
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat()
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat().coerceAtLeast(1f)
)
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
progress = {
when (isEndOfList) {
false -> currentProgress
false -> currentProgress.coerceAtLeast(0f)
true -> 1f
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ fun LearnByTrueFalse(
horizontalAlignment = Alignment.CenterHorizontally
) {
val currentProgress by animateFloatAsState(
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat()
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat().coerceAtLeast(1f)
)
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
progress = {
when (isEndOfList) {
false -> currentProgress
false -> currentProgress.coerceAtLeast(0f)
true -> 1f
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ fun LearnByWrite(
horizontalAlignment = Alignment.CenterHorizontally
) {
val currentProgress by animateFloatAsState(
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat()
targetValue = currentCardIndex.toFloat() / flashCardList.size.toFloat().coerceAtLeast(1f),
)
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
progress = {
when (isEndOfList) {
false -> currentProgress
false -> currentProgress.coerceAtLeast(0f)
true -> 1f
}
},
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/pwhs/quickmem/util/ads/AdsUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object AdsUtil {
)
}

fun rewardedInterstitialAd(context: Context, onAdWatched: () -> Unit) {
fun rewardedInterstitialAd(context: Context, onAdWatched: () -> Unit, onAdLoadFailedToLoad: () -> Unit ) {
// Load an ad
RewardedInterstitialAd.load(
context,
Expand All @@ -101,6 +101,7 @@ object AdsUtil {
super.onAdFailedToLoad(error)
Toast.makeText(context,
context.getString(R.string.txt_no_ads_found), Toast.LENGTH_SHORT).show()
onAdLoadFailedToLoad()
}

override fun onAdLoaded(adLoaded: RewardedInterstitialAd) {
Expand Down

0 comments on commit 47f719f

Please sign in to comment.