Skip to content

Commit

Permalink
Allow to start even if ads can't load
Browse files Browse the repository at this point in the history
  • Loading branch information
Nain57 committed Sep 28, 2024
1 parent 8e7bb57 commit 6c74de4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ internal class InterstitialAdsDataSource @Inject constructor(
}
}

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

coroutineScopeMain.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ internal class RevenueRepository @Inject constructor(
}

override fun showAd(activity: Activity) {
// TODO: Revert error handling once the ads account is no longer limited
if (adsState.value == AdState.ERROR) adsDataSource.onAdDismissed(true)

if (adsState.value != AdState.READY) return
adsDataSource.showAd(activity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ package com.buzbuz.smartautoclicker.feature.revenue.ui.paywall

import android.app.Activity
import android.content.Context

import androidx.lifecycle.ViewModel
import com.buzbuz.smartautoclicker.core.ui.bindings.buttons.LoadableButtonState

import com.buzbuz.smartautoclicker.feature.revenue.domain.model.AdState
import com.buzbuz.smartautoclicker.core.ui.bindings.buttons.LoadableButtonState
import com.buzbuz.smartautoclicker.feature.revenue.R
import com.buzbuz.smartautoclicker.feature.revenue.domain.InternalRevenueRepository
import com.buzbuz.smartautoclicker.feature.revenue.domain.TRIAL_SESSION_DURATION_DURATION
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.AdState
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.ProModeInfo
import com.buzbuz.smartautoclicker.feature.revenue.domain.model.PurchaseState

Expand Down Expand Up @@ -92,11 +91,12 @@ internal sealed class DialogState {
internal data object AdWatched : DialogState()
}


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

AdState.ERROR,
AdState.READY -> LoadableButtonState.Loaded.Enabled(
text = context.getString(R.string.button_text_watch_ad)
)
Expand All @@ -106,8 +106,7 @@ private fun AdState.toAdButtonState(context: Context): LoadableButtonState = whe
text = context.getString(R.string.button_text_watch_ad)
)

AdState.NOT_INITIALIZED,
AdState.ERROR -> LoadableButtonState.Loaded.Disabled(
AdState.NOT_INITIALIZED -> LoadableButtonState.Loaded.Disabled(
text = context.getString(R.string.button_text_watch_ad_error)
)
}
Expand Down

0 comments on commit 6c74de4

Please sign in to comment.