@Override protected void onResume() { super.onResume(); Log.d( Game.class.getName(), "Resume [creating, paused, finished, timerTime] " + creating + " " + paused + " " + finished + " " + timer.getElapsedTime()); if (!creating) { if (fieldCreationFragment.getZahlenschlange() == null) { createGame(); } else if (!paused && finished == GAME_FINISHED_NOT_YET) { startGame(); } else { updateGridView(); } } }
/** * Store elapsed time * * @param save Bundle where the elapsed time will be stored */ private void saveElapsedTime(Bundle save) { if (timer == null) { return; } save.putLong(BUNDLE_ELAPSED_TIME, timer.getElapsedTime()); }
/** Setting the result depending on finishing state and the elapsed time. Use before finish(). */ private void updateResult() { Intent result = new Intent(); result.putExtra(EXTRA_ELAPSED_TIME, (long) timer.getElapsedTime()); result.putExtra(EXTRA_DIFFICULTY, (int) difficulty); result.putExtra(EXTRA_CLICK_COUNT, (int) clickCount); result.putExtra(EXTRA_MAX_NUMBER, (int) getMaxNumber()); setResult((finished == GAME_FINISHED_SUCCESSFUL) ? RESULT_OK : RESULT_CANCELED, result); }
@Override public void onTick(long elapsedTime) { if (timer.getElapsedTime() > MAX_TIME) { timer.stop(); timer.setElapsedTime(MAX_TIME); finishGame(false); } updateTimerTime(); }
@Override protected void onPause() { Log.d( Game.class.getName(), "Pause [creating, paused, finished, timerTime] " + creating + " " + paused + " " + finished + " " + timer.getElapsedTime()); super.onPause(); timer.stop(); }