public void restoreUndo() { if (!undoList.isEmpty()) { UndoState undoState = undoList.removeLast(); GridCell cell = kenKenGrid.mCells.get(undoState.getCellNum()); cell.setUserValue(undoState.getUserValue()); cell.mPossibles = undoState.getPossibles(); if (undoState.getBatch()) restoreUndo(); } if (undoList.isEmpty()) this.actions[2].setVisibility(View.INVISIBLE); }
// called by newGameReady, restoreSaveGame and restartGameDialog public void startFreshGrid(boolean newGame) { undoList.clear(); clearSelectedButton(); this.topLayout.setBackgroundColor(BG_COLOURS[theme]); this.kenKenGrid.setTheme(theme); this.actions[1].setVisibility(View.VISIBLE); this.actions[2].setVisibility(View.INVISIBLE); titleContainer.setBackgroundResource(R.drawable.menu_button); setButtonVisibility(kenKenGrid.mGridSize); if (newGame) { storeStats(true); starttime = System.currentTimeMillis(); mTimerHandler.postDelayed(playTimer, 0); } }
public void saveUndo(GridCell cell, boolean batch) { UndoState undoState = new UndoState(cell.mCellNumber, cell.getUserValue(), cell.mPossibles, batch); undoList.add(undoState); this.actions[2].setVisibility(View.VISIBLE); }