]> git.zerfleddert.de Git - FreeShisen/commitdiff
fix stuff.
authorgitknilch <gitknilch@cwde.de>
Sat, 6 Apr 2013 19:01:21 +0000 (21:01 +0200)
committergitknilch <gitknilch@cwde.de>
Sat, 6 Apr 2013 19:01:21 +0000 (21:01 +0200)
Change-Id: I937e0af4470e8da785eeef2bf176c8ce8b59f5ca
Signed-off-by: gitknilch <gitknilch@cwde.de>
src/de/cwde/freeshisen/ShisenSho.java
src/de/cwde/freeshisen/ShisenShoActivity.java
src/de/cwde/freeshisen/ShisenShoView.java

index a1ee0eb9b4fe73f70550730b9bc6dc2abc24d986..eb7aee384f0922770ffbc20708ceeec4c65e7264 100644 (file)
@@ -1,8 +1,6 @@
 package de.cwde.freeshisen;
 
 package de.cwde.freeshisen;
 
-import android.app.AlertDialog;
 import android.app.Application;
 import android.app.Application;
-import android.content.DialogInterface;
 import android.content.SharedPreferences;
 import android.preference.PreferenceManager;
 import android.util.Log;
 import android.content.SharedPreferences;
 import android.preference.PreferenceManager;
 import android.util.Log;
@@ -21,6 +19,7 @@ public class ShisenSho extends Application {
        public boolean timeCounter=true;
 
        public void newPlay() {
        public boolean timeCounter=true;
 
        public void newPlay() {
+               loadOptions();
                board = new Board();
                board.buildRandomBoard(boardSize[0],boardSize[1],difficulty,gravity);
        }
                board = new Board();
                board.buildRandomBoard(boardSize[0],boardSize[1],difficulty,gravity);
        }
@@ -120,22 +119,7 @@ public class ShisenSho extends Application {
                }
 
                if (needsReset && (view != null) && (activity != null)) {
                }
 
                if (needsReset && (view != null) && (activity != null)) {
-                       new AlertDialog.Builder(this)
-                               .setTitle("Preferences changed!") // FIXME: hardcoded string
-                               .setCancelable(true)
-                               .setIcon(R.drawable.icon)
-                               .setPositiveButton(android.R.string.yes,
-                                       new DialogInterface.OnClickListener() {
-                                       public void onClick(DialogInterface dialog, int id) {
-                                               // User clicked OK button - reset game
-                                               ((ShisenSho) ((AlertDialog) dialog).getContext()).view.reset();
-                                       }
-                               })
-                               .setNegativeButton(android.R.string.no, null)
-                               .setMessage("Changes in Preferences will only have an effect if" +
-                                                       " a new game is started. Abort current game and start" +
-                                                       " a new one?").create() // FIXME: hardcoded string
-                               .show();
+                       activity.onOptionsChanged();
                } else {
                        Log.d("ShisenSho", "Preferences changed, but no view or activity online - huh?");
                }
                } else {
                        Log.d("ShisenSho", "Preferences changed, but no view or activity online - huh?");
                }
index 311c7b126be34799e60a0b654d0ab875667fcd66..0134ad7c29b7e5c1c5d0e65f1d748dc094b70295 100644 (file)
@@ -2,6 +2,7 @@ package de.cwde.freeshisen;
 
 import android.app.Activity;
 import android.app.AlertDialog;
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
@@ -120,4 +121,25 @@ public class ShisenShoActivity extends Activity {
                        e.printStackTrace();
                }
        }
                        e.printStackTrace();
                }
        }
+
+       public void onOptionsChanged()
+       {
+               new AlertDialog.Builder(this)
+               .setTitle("Preferences changed!") // FIXME: hardcoded string
+               .setCancelable(true)
+               .setIcon(R.drawable.icon)
+               .setPositiveButton(android.R.string.yes,
+                               new DialogInterface.OnClickListener() {
+                       public void onClick(DialogInterface dialog, int id) {
+                               // User clicked OK button - reset game
+                               view.reset();
+                       }
+               })
+               .setNegativeButton(android.R.string.no, null)
+               .setMessage("Changes in Preferences will only have an effect if" +
+                               " a new game is started. Abort current game and start" +
+                               " a new one?") // FIXME: hardcoded string
+                               .create()
+                               .show();
+       }
 }
 }
index 3dc6ff007c91b7f6f7561fec3113b1e4c15d04dc..bf4ad9f507866ef7d791239aa686f005128ac086 100644 (file)
@@ -257,7 +257,7 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                try {
                        if (canvas == null) canvas = surfaceHolder.lockCanvas(null);
                        if (canvas == null) return;
                try {
                        if (canvas == null) canvas = surfaceHolder.lockCanvas(null);
                        if (canvas == null) return;
-                       if (cstate==StatePlay.UNINITIALIZED) initializeGame();
+                       if (cstate == StatePlay.UNINITIALIZED) initializeGame();
                        synchronized (surfaceHolder) {
                                doDraw(canvas);
                        }
                        synchronized (surfaceHolder) {
                                doDraw(canvas);
                        }
Impressum, Datenschutz