Skip to content

Commit ce12955

Browse files
committed
fixed bug on saving local high scores in successactivity (check first!)
1 parent 206be4a commit ce12955

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/net/nycjava/skylight1/SuccessActivity.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ public void onCreate(final Bundle savedInstanceState) {
9494

9595
SharedPreferences sharedPreferences = getSharedPreferences(
9696
SKYLIGHT_PREFS_FILE, MODE_PRIVATE);
97-
int globalBestLevelCompleted = sharedPreferences.getInt(
97+
final int globalBestLevelCompleted = sharedPreferences.getInt(
9898
GLOBAL_HIGH_SCORE_PREFERENCE_NAME, -1);
99+
final int localBestLevelCompleted = sharedPreferences.getInt(
100+
HIGH_SCORE_PREFERENCE_NAME, -1);
99101

100-
SharedPreferences.Editor editor = sharedPreferences.edit();
101-
editor.putInt(HIGH_SCORE_PREFERENCE_NAME, bestLevelCompleted);
102-
editor.commit();
103-
102+
if(bestLevelCompleted>localBestLevelCompleted) {
103+
SharedPreferences.Editor editor = sharedPreferences.edit();
104+
editor.putInt(HIGH_SCORE_PREFERENCE_NAME, bestLevelCompleted);
105+
editor.commit();
106+
}
104107
if(globalBestLevelCompleted>0 && bestLevelCompleted > globalBestLevelCompleted) {
105108

106109
globalBestLevel = bestLevelCompleted;

0 commit comments

Comments
 (0)