Skip to content

Commit

Permalink
schedule only on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiu Yue Chun committed Jun 5, 2015
1 parent acaa1d2 commit c9a3e03
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/src/main/java/com/loopbook/cuhk_loopbook/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,24 @@ public void onPageSelected(int position) {
.setTabListener(this));
}

if (savedInstanceState == null) { CheckSched.scheduleNotification(this); }
if (savedInstanceState == null && isFirstRun()) {
if (BuildInfo.DEBUG)
Toast.makeText(this, "firstrun", Toast.LENGTH_LONG).show();
setRunned();
CheckSched.scheduleNotification(this);
}
}

public boolean isFirstRun() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
return prefs.getBoolean("firstrun", true);
}

public void setRunned() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("firstrun", false);
editor.commit();
}

@Override
Expand Down

0 comments on commit c9a3e03

Please sign in to comment.