diff --git a/app/src/main/java/com/pwhs/quickmem/presentation/app/explore/ExploreScreen.kt b/app/src/main/java/com/pwhs/quickmem/presentation/app/explore/ExploreScreen.kt index 1157c104..8663000f 100644 --- a/app/src/main/java/com/pwhs/quickmem/presentation/app/explore/ExploreScreen.kt +++ b/app/src/main/java/com/pwhs/quickmem/presentation/app/explore/ExploreScreen.kt @@ -232,10 +232,14 @@ fun Explore( isGettingAds = true AdsUtil.rewardedInterstitialAd( context, - ) { - onEarnCoins() - isGettingAds = false - } + onAdLoadFailedToLoad = { + isGettingAds = false + }, + onAdWatched = { + onEarnCoins() + isGettingAds = false + } + ) }, ) } diff --git a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/quiz/LearnByQuizScreen.kt b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/quiz/LearnByQuizScreen.kt index 2c562a57..0105e858 100644 --- a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/quiz/LearnByQuizScreen.kt +++ b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/quiz/LearnByQuizScreen.kt @@ -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 } }, diff --git a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/true_false/LearnByTrueFalseScreen.kt b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/true_false/LearnByTrueFalseScreen.kt index f1f6fc4a..4186909b 100644 --- a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/true_false/LearnByTrueFalseScreen.kt +++ b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/true_false/LearnByTrueFalseScreen.kt @@ -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 } }, diff --git a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/write/LearnByWriteScreen.kt b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/write/LearnByWriteScreen.kt index c84864f9..b657a7b4 100644 --- a/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/write/LearnByWriteScreen.kt +++ b/app/src/main/java/com/pwhs/quickmem/presentation/app/study_set/studies/write/LearnByWriteScreen.kt @@ -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 } }, diff --git a/app/src/main/java/com/pwhs/quickmem/util/ads/AdsUtil.kt b/app/src/main/java/com/pwhs/quickmem/util/ads/AdsUtil.kt index 53013d68..0e27841f 100644 --- a/app/src/main/java/com/pwhs/quickmem/util/ads/AdsUtil.kt +++ b/app/src/main/java/com/pwhs/quickmem/util/ads/AdsUtil.kt @@ -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, @@ -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) {