Fix critical finish() bug

This commit is contained in:
Ruben 2017-09-08 10:05:43 +02:00
parent 5a76d03d58
commit 5f840969a0
6 changed files with 11 additions and 13 deletions

View File

@ -397,15 +397,13 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
// scores.add(score); // scores.add(score);
player.savePlayerInfo(playerInfo); player.savePlayerInfo(playerInfo);
finish();
GameOpenHelper gameHelper = new GameOpenHelper(getApplicationContext()); GameOpenHelper gameHelper = new GameOpenHelper(getApplicationContext());
gameHelper.insertGame(currentScenario.game); gameHelper.insertGame(currentScenario.game);
Log.d(LOG_TAG, "WHYYYY won't it work?!!! ;-)");
Intent intent = new Intent(this, ReviewActivity.class); Intent intent = new Intent(this, ReviewActivity.class);
intent.putExtra(ReviewActivity.INTENT_EXTRA_GAME_ID, currentScenario.game.id); intent.putExtra(ReviewActivity.INTENT_EXTRA_GAME_ID, currentScenario.game.id);
intent.putExtra(ReviewActivity.INTENT_EXTRA_FROM_GAME, true); intent.putExtra(ReviewActivity.INTENT_EXTRA_FROM_GAME, true);
startActivity(intent); startActivity(intent);
finish();
} }
} }

View File

@ -329,8 +329,8 @@ public class HighscoreActivity extends AppCompatActivity {
getContext().getResources().getString(R.string.load_game_activity), true); getContext().getResources().getString(R.string.load_game_activity), true);
Intent intent = new Intent(getContext(), GamingActivity.class); Intent intent = new Intent(getContext(), GamingActivity.class);
intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, scenario.id); intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, scenario.id);
getActivity().finish();
startActivity(intent); startActivity(intent);
getActivity().finish();
} }
}); });
} else { } else {

View File

@ -90,9 +90,9 @@ public class IntroActivity extends AppCompatActivity {
public void continueToMenu() { public void continueToMenu() {
continueHandler.removeCallbacks(continueRunnable); continueHandler.removeCallbacks(continueRunnable);
Intent intent = new Intent(this, MirrorMenuActivity.class); Intent intent = new Intent(this, MirrorMenuActivity.class);
finish();
startActivity(intent); startActivity(intent);
//disable distracting transition when going to menu //disable distracting transition when going to menu
IntroActivity.this.overridePendingTransition(0, 0); IntroActivity.this.overridePendingTransition(0, 0);
finish();
} }
} }

View File

@ -240,8 +240,9 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class); Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
finish();
startActivity(intent); startActivity(intent);
stopDetector();
finish();
} }
}); });
@ -249,8 +250,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
showSettings(); showSettings();
} }
// all setup, see wheter we immediately continue to intro: // all setup, see wheter we immediately continue to intro:
boolean showIntro = getIntent().getBooleanExtra(INTENT_EXTRA_SHOW_INTRO, false); boolean showIntro = getIntent().getBooleanExtra(INTENT_EXTRA_SHOW_INTRO, false);
if(showIntro) { if(showIntro) {

View File

@ -204,8 +204,8 @@ public class ProgressActivity extends AppCompatActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), EndingActivity.class); Intent intent = new Intent(getApplicationContext(), EndingActivity.class);
finish();
startActivity(intent); startActivity(intent);
finish();
} }
}); });
} }

View File

@ -207,8 +207,9 @@ public class ReviewActivity extends AppCompatActivity {
intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, game.scenario.id); intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, game.scenario.id);
ProgressDialog dialog = ProgressDialog.show(ReviewActivity.this, "", ProgressDialog dialog = ProgressDialog.show(ReviewActivity.this, "",
getApplicationContext().getResources().getString(R.string.load_game_activity), true); getApplicationContext().getResources().getString(R.string.load_game_activity), true);
finish();
startActivity(intent); startActivity(intent);
finish();
} }
}); });
@ -229,8 +230,8 @@ public class ReviewActivity extends AppCompatActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), EndingActivity.class); Intent intent = new Intent(getApplicationContext(), EndingActivity.class);
finish();
startActivity(intent); startActivity(intent);
finish();
} }
}); });
} else { } else {
@ -241,8 +242,8 @@ public class ReviewActivity extends AppCompatActivity {
intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, game.scenario.getNextLevelId()); intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, game.scenario.getNextLevelId());
ProgressDialog dialog = ProgressDialog.show(ReviewActivity.this, "", ProgressDialog dialog = ProgressDialog.show(ReviewActivity.this, "",
getApplicationContext().getResources().getString(R.string.load_game_activity), true); getApplicationContext().getResources().getString(R.string.load_game_activity), true);
finish();
startActivity(intent); startActivity(intent);
finish();
} }
}); });
} }
@ -343,8 +344,8 @@ public class ReviewActivity extends AppCompatActivity {
if(fromGame) { if(fromGame) {
Intent intent = new Intent(getApplicationContext(), HighscoreActivity.class); Intent intent = new Intent(getApplicationContext(), HighscoreActivity.class);
intent.putExtra(HighscoreActivity.INTENT_EXTRA_GAME_ID, game.id); intent.putExtra(HighscoreActivity.INTENT_EXTRA_GAME_ID, game.id);
finish();
startActivity(intent); startActivity(intent);
finish();
} else { } else {
onBackPressed(); onBackPressed();
} }