This commit is contained in:
Christopher Beckmann 2017-06-29 14:34:08 +02:00
parent 1aa5500c64
commit 7a3347718a
4 changed files with 23 additions and 20 deletions

View file

@ -771,7 +771,7 @@ public class GameController implements IModelChangedListener, Parcelable {
out.writeParcelable(gameType, 0);
out.writeParcelable(difficulty, 0);
out.writeParcelable(gameBoard, 0);
out.writeParcelable(undoRedoManager, 0);
//out.writeParcelable(undoRedoManager, 0);
out.writeTypedList(errorList);
}
@ -809,7 +809,7 @@ public class GameController implements IModelChangedListener, Parcelable {
gameType = in.readParcelable(GameType.class.getClassLoader());
difficulty = in.readParcelable(GameDifficulty.class.getClassLoader());
gameBoard = in.readParcelable(GameBoard.class.getClassLoader());
undoRedoManager = in.readParcelable(UndoRedoManager.class.getClassLoader());
undoRedoManager = new UndoRedoManager(gameBoard);//*/in.readParcelable(UndoRedoManager.class.getClassLoader());
in.readTypedList(errorList, CellConflict.CREATOR);

View file

@ -6,6 +6,7 @@ import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
@ -26,6 +27,7 @@ import org.secuso.privacyfriendlysudoku.ui.MainActivity;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import java.util.Date;
import java.util.IllegalFormatCodePointException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@ -50,12 +52,16 @@ public class GeneratorService extends IntentService {
private final List<Pair<GameType, GameDifficulty>> generationList = new LinkedList<>();
private final DatabaseHelper dbHelper = new DatabaseHelper(this);
//private Handler mHandler = new Handler();
public GeneratorService() {
super("Generator Service");
}
public GeneratorService(String name) { super(name); }
private void buildGenerationList() {
generationList.clear();
@ -80,14 +86,21 @@ public class GeneratorService extends IntentService {
private void handleGenerationStop() {
stopForeground(true);
stopSelf();
//mHandler.removeCallbacksAndMessages(null);
}
private void handleGenerationStart(Intent intent) {
GameType gameType = intent.getParcelableExtra(EXTRA_GAMETYPE);
GameDifficulty gameDifficulty = intent.getParcelableExtra(EXTRA_DIFFICULTY);
GameType gameType;
GameDifficulty gameDifficulty;
try {
gameType = GameType.valueOf(intent.getExtras().getString(EXTRA_GAMETYPE, ""));
gameDifficulty = GameDifficulty.valueOf(intent.getExtras().getString(EXTRA_DIFFICULTY, ""));
} catch(IllegalArgumentException | NullPointerException e) {
gameType = null;
gameDifficulty = null;
}
if(gameType == null || gameDifficulty == null) {
if(gameType == null) {
generateLevels();
} else {
generateLevel(gameType, gameDifficulty);
@ -253,13 +266,6 @@ public class GeneratorService extends IntentService {
builder.setSmallIcon(R.drawable.splash_icon);
startForeground(50, builder.build());
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
if (intent != null) {

View file

@ -96,11 +96,8 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
Bundle extras = getIntent().getExtras();
if (extras != null) {
Object o = extras.get("gameType");
if (o instanceof GameType) {
gameType = (GameType) extras.get("gameType");
}
gameDifficulty = (GameDifficulty) (extras.get("gameDifficulty"));
gameType = GameType.valueOf(extras.getString("gameType", GameType.Default_9x9.name()));
gameDifficulty = GameDifficulty.valueOf(extras.getString("gameDifficulty", GameDifficulty.Moderate.name()));
loadLevel = extras.getBoolean("loadLevel", false);
if (loadLevel) {
loadLevelID = extras.getInt("loadLevelID");

View file

@ -215,8 +215,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
// send everything to game activity
i = new Intent(this, GameActivity.class);
i.putExtra("gameType", (Serializable)gameType);
i.putExtra("gameDifficulty", (Serializable)gameDifficulty);
i.putExtra("gameType", gameType.name());
i.putExtra("gameDifficulty", gameDifficulty.name());
} else {
newLevelManager.checkAndRestock();
Toast t = Toast.makeText(getApplicationContext(), R.string.generating, Toast.LENGTH_SHORT);