Skip to content

Commit

Permalink
Fix showEvery(int) method
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Feb 5, 2016
1 parent 3ca687a commit 415b104
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ protected void onPostExecute(String version) {

if (UtilsLibrary.isUpdateAvailable(UtilsLibrary.getAppInstalledVersion(context), version)) {
Integer successfulChecks = libraryPreferences.getSuccessfulChecks();
libraryPreferences.setSuccessfulChecks(successfulChecks++);
if (UtilsLibrary.isAbleToShow(context, showEvery)) {
if (UtilsLibrary.isAbleToShow(successfulChecks, showEvery)) {
switch (display) {
case DIALOG:
UtilsDisplay.showUpdateAvailableDialog(context, context.getResources().getString(R.string.appupdater_update_available), String.format(context.getResources().getString(R.string.appupdater_update_available_description_dialog), version, UtilsLibrary.getAppName(context)), updateFrom, gitHub);
Expand All @@ -73,6 +72,7 @@ protected void onPostExecute(String version) {
break;
}
}
libraryPreferences.setSuccessfulChecks(successfulChecks + 1);
} else if (showAppUpdated) {
switch (display) {
case DIALOG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ static void goToUpdate(Context context, UpdateFrom updateFrom, GitHub gitHub) {
}
}

static Boolean isAbleToShow(Context context, Integer showEvery) {
LibraryPreferences libraryPreferences = new LibraryPreferences(context);
return libraryPreferences.getSuccessfulChecks() % showEvery == 0;
static Boolean isAbleToShow(Integer successfulChecks, Integer showEvery) {
return successfulChecks % showEvery == 0;
}

static Boolean isNetworkAvailable(Context context) {
Expand Down

0 comments on commit 415b104

Please sign in to comment.