Skip to content

Commit 6c74de4

Browse files
committed
Allow to start even if ads can't load
1 parent 8e7bb57 commit 6c74de4

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

feature/revenue/src/playStore/java/com/buzbuz/smartautoclicker/feature/revenue/data/ads/InterstitialAdsDataSource.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ internal class InterstitialAdsDataSource @Inject constructor(
168168
}
169169
}
170170

171-
private fun onAdDismissed(impression: Boolean) {
171+
// TODO: Revert to private once the ads account is no longer limited
172+
internal fun onAdDismissed(impression: Boolean) {
172173
Log.i(TAG, "onAdDismissed, impression=$impression")
173174

174175
coroutineScopeMain.launch {

feature/revenue/src/playStore/java/com/buzbuz/smartautoclicker/feature/revenue/domain/RevenueRepository.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ internal class RevenueRepository @Inject constructor(
170170
}
171171

172172
override fun showAd(activity: Activity) {
173+
// TODO: Revert error handling once the ads account is no longer limited
174+
if (adsState.value == AdState.ERROR) adsDataSource.onAdDismissed(true)
175+
173176
if (adsState.value != AdState.READY) return
174177
adsDataSource.showAd(activity)
175178
}

feature/revenue/src/playStore/java/com/buzbuz/smartautoclicker/feature/revenue/ui/paywall/PaywallViewModel.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ package com.buzbuz.smartautoclicker.feature.revenue.ui.paywall
1818

1919
import android.app.Activity
2020
import android.content.Context
21-
2221
import androidx.lifecycle.ViewModel
23-
import com.buzbuz.smartautoclicker.core.ui.bindings.buttons.LoadableButtonState
2422

25-
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.AdState
23+
import com.buzbuz.smartautoclicker.core.ui.bindings.buttons.LoadableButtonState
2624
import com.buzbuz.smartautoclicker.feature.revenue.R
2725
import com.buzbuz.smartautoclicker.feature.revenue.domain.InternalRevenueRepository
2826
import com.buzbuz.smartautoclicker.feature.revenue.domain.TRIAL_SESSION_DURATION_DURATION
27+
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.AdState
2928
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.ProModeInfo
3029
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.PurchaseState
3130

@@ -92,11 +91,12 @@ internal sealed class DialogState {
9291
internal data object AdWatched : DialogState()
9392
}
9493

95-
94+
// TODO: Revert error handling once the ads account is no longer limited
9695
private fun AdState.toAdButtonState(context: Context): LoadableButtonState = when (this) {
9796
AdState.INITIALIZED,
9897
AdState.LOADING -> LoadableButtonState.Loading
9998

99+
AdState.ERROR,
100100
AdState.READY -> LoadableButtonState.Loaded.Enabled(
101101
text = context.getString(R.string.button_text_watch_ad)
102102
)
@@ -106,8 +106,7 @@ private fun AdState.toAdButtonState(context: Context): LoadableButtonState = whe
106106
text = context.getString(R.string.button_text_watch_ad)
107107
)
108108

109-
AdState.NOT_INITIALIZED,
110-
AdState.ERROR -> LoadableButtonState.Loaded.Disabled(
109+
AdState.NOT_INITIALIZED -> LoadableButtonState.Loaded.Disabled(
111110
text = context.getString(R.string.button_text_watch_ad_error)
112111
)
113112
}

0 commit comments

Comments
 (0)