From 327f9a6c66c29d6a38c5c46a615ddb80ea663b77 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Thu, 19 Nov 2015 15:33:29 +0100 Subject: [PATCH] Bugfix. Runnable again. --- .../sudoku/controller/GameController.java | 11 +++++++++-- .../sudoku/controller/helper/GameInfoContainer.java | 4 ++++ .../main/java/tu_darmstadt/sudoku/game/GameBoard.java | 1 - .../main/java/tu_darmstadt/sudoku/game/GameType.java | 2 +- .../java/tu_darmstadt/sudoku/ui/MainActivity.java | 2 +- app/src/main/res/layout/activity_main_menu.xml | 2 -- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java b/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java index 5facbf1..648c5d0 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java +++ b/app/src/main/java/tu_darmstadt/sudoku/controller/GameController.java @@ -34,6 +34,7 @@ public class GameController implements IModelChangedListener { private int selectedCol; private SharedPreferences settings; private int gameID = 0; + private GameDifficulty difficulty; private CellConflictList errorList = new CellConflictList(); private int selectedValue; private LinkedList solvedListeners = new LinkedList<>(); @@ -51,9 +52,8 @@ public class GameController implements IModelChangedListener { public GameController(GameType type, SharedPreferences pref) { setGameType(type); - gameBoard = new GameBoard(type); - gameBoard.registerOnModelChangeListener(this); setSettings(pref); + gameBoard = new GameBoard(type); } public int getGameID() { @@ -112,6 +112,7 @@ public class GameController implements IModelChangedListener { int[] setValues = gic.getSetValues(); boolean[][] setNotes = gic.getSetNotes(); this.gameID = gic.getID(); + this.difficulty = gic.getDifficulty(); setGameType(gic.getGameType()); this.gameBoard = new GameBoard(gic.getGameType()); @@ -142,6 +143,8 @@ public class GameController implements IModelChangedListener { } } + gameBoard.registerOnModelChangeListener(this); + // call the solve function to get the solution of this board solve(); } @@ -303,6 +306,10 @@ public class GameController implements IModelChangedListener { return c.getNotes().clone(); } + public GameDifficulty getDifficulty() { + return difficulty; + } + public void deleteNote(int row, int col, int value) { GameCell c = gameBoard.getCell(row,col); c.deleteNote(value); diff --git a/app/src/main/java/tu_darmstadt/sudoku/controller/helper/GameInfoContainer.java b/app/src/main/java/tu_darmstadt/sudoku/controller/helper/GameInfoContainer.java index dd92cf0..090255d 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/controller/helper/GameInfoContainer.java +++ b/app/src/main/java/tu_darmstadt/sudoku/controller/helper/GameInfoContainer.java @@ -117,6 +117,10 @@ public class GameInfoContainer { return setNotes; } + public GameDifficulty getDifficulty() { + return difficulty; + } + public int getID() { return ID; } diff --git a/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java b/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java index fa481d9..ba35235 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java +++ b/app/src/main/java/tu_darmstadt/sudoku/game/GameBoard.java @@ -215,7 +215,6 @@ public class GameBoard implements Cloneable { public void registerOnModelChangeListener(final IModelChangedListener listener) { if(!modelChangedListeners.contains(listener)) { actionOnCells(new ICellAction() { - @Override public Boolean action(GameCell gc, Boolean existing) { gc.registerOnModelChangeListener(listener); diff --git a/app/src/main/java/tu_darmstadt/sudoku/game/GameType.java b/app/src/main/java/tu_darmstadt/sudoku/game/GameType.java index 06f49a4..eb01eeb 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/game/GameType.java +++ b/app/src/main/java/tu_darmstadt/sudoku/game/GameType.java @@ -27,7 +27,7 @@ public enum GameType { this.size = size; this.sectionHeight = sectionHeight; this.sectionWidth = sectionWidth; - this.resIDString = this.resIDString; + this.resIDString = resIDString; } public static List getValidGameTypes() { diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java index 449b604..f0674c3 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/MainActivity.java @@ -96,7 +96,7 @@ public class MainActivity extends AppCompatActivity { } }); int lastChosenDifficulty = settings.getInt("lastChosenDifficulty", 1); - difficultyBar.setProgress(lastChosenDifficulty); + difficultyBar.setRating(lastChosenDifficulty); // on first create always check for loadable levels! SharedPreferences.Editor editor = settings.edit(); diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml index 6a1c239..36a45b7 100644 --- a/app/src/main/res/layout/activity_main_menu.xml +++ b/app/src/main/res/layout/activity_main_menu.xml @@ -52,8 +52,6 @@ android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="tu_darmstadt.sudoku.ui.MainActivity" - android:layout_centerHorizontal="true" - android:layout_centerVertical="true" android:orientation="vertical" android:weightSum="8" android:divider="#000"