From 317482842790ea5ec6c78ed9b88c6d4067d0dd71 Mon Sep 17 00:00:00 2001 From: Ibrahim Gabol Date: Sat, 5 Oct 2024 23:50:14 +0100 Subject: [PATCH] #173 Re-opening app from in-progress TrainingActivity will lead to TrainingActivity --- .../activities/TrainingOverviewActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlyactivitytracker/activities/TrainingOverviewActivity.java b/app/src/main/java/org/secuso/privacyfriendlyactivitytracker/activities/TrainingOverviewActivity.java index b4180be..901c436 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyactivitytracker/activities/TrainingOverviewActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlyactivitytracker/activities/TrainingOverviewActivity.java @@ -74,11 +74,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_training_overview); - if(TrainingPersistenceHelper.getActiveItem(this) != null){ - // show current training session if there is one. - Log.w(LOG_CLASS, "Found active training session"); - startTrainingActivity(); - } + checkForActiveTrainingSession(); mEmptyView = findViewById(R.id.empty_view); @@ -119,10 +115,19 @@ public void onClick(View v) { @Override public void onResume() { super.onResume(); + checkForActiveTrainingSession(); // Force refresh of trainings. showTrainings(); } + private void checkForActiveTrainingSession() { + if (TrainingPersistenceHelper.getActiveItem(this) != null) { + // show current training session if there is one. + Log.w(LOG_CLASS, "Found active training session"); + startTrainingActivity(); + } + } + protected void startTrainingActivity(){ Intent intent = new Intent(this, TrainingActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);