ErrorList is now updated when the field is updated.
This commit is contained in:
parent
ad4eb476f9
commit
6e96ee8904
3 changed files with 23 additions and 10 deletions
|
@ -14,7 +14,6 @@ import org.secuso.privacyfriendlysudoku.game.GameCell;
|
||||||
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
||||||
import org.secuso.privacyfriendlysudoku.game.GameType;
|
import org.secuso.privacyfriendlysudoku.game.GameType;
|
||||||
import org.secuso.privacyfriendlysudoku.game.ICellAction;
|
import org.secuso.privacyfriendlysudoku.game.ICellAction;
|
||||||
import org.secuso.privacyfriendlysudoku.game.listener.IGameErrorListener;
|
|
||||||
import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener;
|
import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener;
|
||||||
import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
|
import org.secuso.privacyfriendlysudoku.game.listener.IHighlightChangedListener;
|
||||||
import org.secuso.privacyfriendlysudoku.game.listener.IHintListener;
|
import org.secuso.privacyfriendlysudoku.game.listener.IHintListener;
|
||||||
|
@ -45,7 +44,6 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
private LinkedList<IHighlightChangedListener> highlightListeners = new LinkedList<>();
|
private LinkedList<IHighlightChangedListener> highlightListeners = new LinkedList<>();
|
||||||
private LinkedList<IGameSolvedListener> solvedListeners = new LinkedList<>();
|
private LinkedList<IGameSolvedListener> solvedListeners = new LinkedList<>();
|
||||||
private LinkedList<IHintListener> hintListener = new LinkedList<>();
|
private LinkedList<IHintListener> hintListener = new LinkedList<>();
|
||||||
private LinkedList<IGameErrorListener> errorListeners = new LinkedList<>();
|
|
||||||
private boolean notifiedOnSolvedListeners = false;
|
private boolean notifiedOnSolvedListeners = false;
|
||||||
|
|
||||||
// Game
|
// Game
|
||||||
|
@ -207,7 +205,6 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
public void setValue(int row, int col, int value) {
|
public void setValue(int row, int col, int value) {
|
||||||
GameCell cell = gameBoard.getCell(row, col);
|
GameCell cell = gameBoard.getCell(row, col);
|
||||||
if (!cell.isFixed() && isValidNumber(value)) {
|
if (!cell.isFixed() && isValidNumber(value)) {
|
||||||
cell.deleteNotes();
|
|
||||||
cell.setValue(value);
|
cell.setValue(value);
|
||||||
|
|
||||||
if(settings != null && settings.getBoolean("pref_automatic_note_deletion",true)) {
|
if(settings != null && settings.getBoolean("pref_automatic_note_deletion",true)) {
|
||||||
|
@ -323,7 +320,6 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
if(!c.isFixed()) {
|
if(!c.isFixed()) {
|
||||||
c.setValue(0);
|
c.setValue(0);
|
||||||
//notifyListeners();
|
//notifyListeners();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -507,6 +503,9 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModelChange(GameCell c) {
|
public void onModelChange(GameCell c) {
|
||||||
|
|
||||||
|
checkErrorList();
|
||||||
|
|
||||||
if(gameBoard.isFilled()) {
|
if(gameBoard.isFilled()) {
|
||||||
errorList = new CellConflictList();
|
errorList = new CellConflictList();
|
||||||
if(gameBoard.isSolved(errorList)) {
|
if(gameBoard.isSolved(errorList)) {
|
||||||
|
@ -525,6 +524,16 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkErrorList() {
|
||||||
|
LinkedList<CellConflict> toRemove = new LinkedList<>();
|
||||||
|
for(CellConflict cc : errorList) {
|
||||||
|
if(cc.getCell1().getValue() != cc.getCell2().getValue()) {
|
||||||
|
toRemove.add(cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
errorList.removeAll(toRemove);
|
||||||
|
}
|
||||||
|
|
||||||
public void resetSelects() {
|
public void resetSelects() {
|
||||||
selectedCol = -1;
|
selectedCol = -1;
|
||||||
selectedRow = -1;
|
selectedRow = -1;
|
||||||
|
@ -774,7 +783,6 @@ public class GameController implements IModelChangedListener, Parcelable {
|
||||||
solvedListeners = new LinkedList<>();
|
solvedListeners = new LinkedList<>();
|
||||||
hintListener = new LinkedList<>();
|
hintListener = new LinkedList<>();
|
||||||
timerListeners = new LinkedList<>();
|
timerListeners = new LinkedList<>();
|
||||||
errorListeners = new LinkedList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContextAndSettings(Context applicationContext, SharedPreferences sharedPref) {
|
public void setContextAndSettings(Context applicationContext, SharedPreferences sharedPref) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class CellConflict implements Parcelable {
|
||||||
return c2.getCol();
|
return c2.getCol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameCell getCell1() { return c1; }
|
||||||
|
public GameCell getCell2() { return c2; }
|
||||||
|
|
||||||
public CellConflict(GameCell first, GameCell second) {
|
public CellConflict(GameCell first, GameCell second) {
|
||||||
c1 = first;
|
c1 = first;
|
||||||
|
|
|
@ -28,11 +28,8 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.RatingBar;
|
import android.widget.RatingBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.secuso.privacyfriendlysudoku.controller.GameStateManager;
|
|
||||||
import org.secuso.privacyfriendlysudoku.controller.GameController;
|
import org.secuso.privacyfriendlysudoku.controller.GameController;
|
||||||
|
import org.secuso.privacyfriendlysudoku.controller.GameStateManager;
|
||||||
import org.secuso.privacyfriendlysudoku.controller.SaveLoadStatistics;
|
import org.secuso.privacyfriendlysudoku.controller.SaveLoadStatistics;
|
||||||
import org.secuso.privacyfriendlysudoku.controller.Symbol;
|
import org.secuso.privacyfriendlysudoku.controller.Symbol;
|
||||||
import org.secuso.privacyfriendlysudoku.controller.helper.GameInfoContainer;
|
import org.secuso.privacyfriendlysudoku.controller.helper.GameInfoContainer;
|
||||||
|
@ -42,11 +39,14 @@ import org.secuso.privacyfriendlysudoku.game.listener.IGameSolvedListener;
|
||||||
import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener;
|
import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
|
import org.secuso.privacyfriendlysudoku.ui.listener.IHintDialogFragmentListener;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener;
|
import org.secuso.privacyfriendlysudoku.ui.listener.IResetDialogFragmentListener;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.WinDialog;
|
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.R;
|
import org.secuso.privacyfriendlysudoku.ui.view.R;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout;
|
import org.secuso.privacyfriendlysudoku.ui.view.SudokuFieldLayout;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout;
|
import org.secuso.privacyfriendlysudoku.ui.view.SudokuKeyboardLayout;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.SudokuSpecialButtonLayout;
|
import org.secuso.privacyfriendlysudoku.ui.view.SudokuSpecialButtonLayout;
|
||||||
|
import org.secuso.privacyfriendlysudoku.ui.view.WinDialog;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GameActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener, IHintDialogFragmentListener, IResetDialogFragmentListener {
|
public class GameActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IGameSolvedListener ,ITimerListener, IHintDialogFragmentListener, IResetDialogFragmentListener {
|
||||||
|
|
||||||
|
@ -184,6 +184,9 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
|
||||||
gameController.notifyHighlightChangedListeners();
|
gameController.notifyHighlightChangedListeners();
|
||||||
gameController.notifyTimerListener(gameController.getTime());
|
gameController.notifyTimerListener(gameController.getTime());
|
||||||
|
|
||||||
|
// run this so the error list gets build again.
|
||||||
|
gameController.onModelChange(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue