Fix bug in the MainActivity which made it possible for neither the circle checkbox nor the rating bar to be selected

This commit is contained in:
uykek 2020-08-29 10:04:11 +02:00
parent ee0ceceeb7
commit e32cb3a4df

View file

@ -84,10 +84,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = PreferenceManager.getDefaultSharedPreferences(this); settings = PreferenceManager.getDefaultSharedPreferences(this);
if (settings.getBoolean("pref_dark_mode_setting", false )) { if (settings.getBoolean("pref_dark_mode_setting", false )) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
@ -101,6 +97,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
} }
super.onCreate(savedInstanceState);
NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings); NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings);
// check if we need to pre generate levels. // check if we need to pre generate levels.
@ -170,12 +168,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
@Override @Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
createGameBar.setChecked(false); createGameBar.setChecked(false);
((Button) findViewById(R.id.playButton)).setText("New Game"); ((Button) findViewById(R.id.playButton)).setText(R.string.new_game);
if (rating >= 1) { if (rating >= 1) {
difficultyText.setText(getString(difficultyList.get((int) ratingBar.getRating() - 1).getStringResID())); difficultyText.setText(getString(difficultyList.get((int) ratingBar.getRating() - 1).getStringResID()));
} else { } else {
difficultyText.setText("Custom Sudoku"); difficultyText.setText(R.string.difficulty_custom);
createGameBar.setChecked(true);
((Button)findViewById(R.id.playButton)).setText(R.string.create_game);
} }
} }
}); });
@ -186,7 +186,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
if (isChecked) { if (isChecked) {
difficultyBar.setRating(0); difficultyBar.setRating(0);
((Button)findViewById(R.id.playButton)).setText("Create"); ((Button)findViewById(R.id.playButton)).setText(R.string.create_game);
} }
createGameBar.setChecked(isChecked); createGameBar.setChecked(isChecked);
}}); }});