Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setRemindLaunchTimes() #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions library/src/main/java/hotchemi/android/rate/AppRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public final class AppRate {

private int remindInterval = 1;

private int remindLaunchTimes = 0;

private boolean isDebug = false;

private AppRate(Context context) {
Expand Down Expand Up @@ -72,6 +74,11 @@ public AppRate setRemindInterval(int remindInterval) {
return this;
}

public AppRate setRemindLaunchTimes(int remindLaunchTimes) {
this.remindLaunchTimes = remindLaunchTimes;
return this;
}

public AppRate setShowLaterButton(boolean isShowNeutralButton) {
options.setShowNeutralButton(isShowNeutralButton);
return this;
Expand Down Expand Up @@ -189,6 +196,7 @@ public void showRateDialog(Activity activity) {
public boolean shouldShowRateDialog() {
return getIsAgreeShowDialog(context) &&
isOverLaunchTimes() &&
isOverRemindLaunchTimes() &&
isOverInstallDate() &&
isOverRemindDate();
}
Expand All @@ -197,6 +205,8 @@ private boolean isOverLaunchTimes() {
return getLaunchTimes(context) >= launchTimes;
}

private boolean isOverRemindLaunchTimes() { return remindLaunchTimes != 0 && getLaunchTimes(context) % remindLaunchTimes == 0; }

private boolean isOverInstallDate() {
return isOverDate(getInstallDate(context), installDate);
}
Expand Down