X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/FreeShisen/blobdiff_plain/42aa846accf450791edf0b254db044867179eb41..9054c57fa930d44c3b45a214d7ca1bf6601667b2:/src/de/cwde/shisensho/ShisenSho.java diff --git a/src/de/cwde/shisensho/ShisenSho.java b/src/de/cwde/shisensho/ShisenSho.java index 654e4e0..0ca4ede 100644 --- a/src/de/cwde/shisensho/ShisenSho.java +++ b/src/de/cwde/shisensho/ShisenSho.java @@ -9,10 +9,10 @@ public class ShisenSho extends Application { private static ShisenSho instance = null; private ShisenShoView view = null; public ShisenShoActivity activity = null; - + public Board board; public int[] boardSize=new int[2]; - public int difficulty=1; // 1=Hard, 2=Easy + public int difficulty=1; // 1=Easy, 2=Hard public int size=3; // 1=Small, 2=Medium, 3=Big public boolean gravity=true; public boolean timeCounter=true; @@ -57,38 +57,40 @@ public class ShisenSho extends Application { instance = this; setSize(size); } - + public static synchronized ShisenSho app() { return instance; } - + public ShisenShoView getView() { if (view == null) view = new ShisenShoView(this); return view; } - + /** Called when the activity is first created. */ - @Override - public void onCreate() { - super.onCreate(); - PreferenceManager.setDefaultValues(this, R.xml.preferences, false); - } - + @Override + public void onCreate() { + super.onCreate(); + PreferenceManager.setDefaultValues(this, R.xml.preferences, false); + setOptions(); + } + public void setOptions() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - - int size = sharedPref.getInt("size", 1); - int difficulty = sharedPref.getInt("difficulty", 1); - boolean gravity = sharedPref.getBoolean("gravity", true); - boolean timeCounter = sharedPref.getBoolean("timeCounter", true); + + // FIXME: handle NumberFormatException here? + int size = Integer.parseInt(sharedPref.getString("pref_size", "1")); + int difficulty = Integer.parseInt(sharedPref.getString("pref_diff", "1")); + boolean gravity = sharedPref.getBoolean("pref_grav", true); + boolean timeCounter = sharedPref.getBoolean("pref_time", true); boolean needsReset = false; - + if (size != this.size) { setSize(size); needsReset = true; } - + if (difficulty != this.difficulty) { this.difficulty = difficulty; needsReset = true; @@ -98,13 +100,13 @@ public class ShisenSho extends Application { this.gravity = gravity; needsReset = true; } - + if (timeCounter != this.timeCounter) { this.timeCounter = timeCounter; view.onTimeCounterActivate(); } - if (needsReset) { + if (needsReset && (view != null)) { view.reset(); } }