Last active
August 22, 2019 10:05
-
-
Save IvanShafran/9a2d5d4f3e4cf5787e7b99a048bf4dc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShowRateUsLogic( | |
private val rateUsPreferences: RateUsPreferences, | |
private val buyPreferences: BuyPreferences, | |
private val time: Time | |
) { | |
fun shouldShowRateUs(): Boolean { | |
val timeFromLastShown = time.getCurrentTimeMillis() - rateUsPreferences.getLastShownTimeMillis() | |
return when { | |
// User doesn't want to see "rate us" again | |
rateUsPreferences.isNeverShownAgainClicked() -> false | |
// User already rated the app | |
rateUsPreferences.isRateNowClicked() -> false | |
// "Rate us" should be shown after 2 "buy" clicked | |
buyPreferences.getBuyCount() < 2 -> false | |
// Show "rate us" only first time or if passed two months since last shown time | |
timeFromLastShown < TimeUnit.DAYS.toMillis(60) -> false | |
else -> true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment