Skip to content

Commit

Permalink
Fix waypoint remove before exit
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Feb 2, 2024
1 parent d4ee030 commit cefca14
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/mobi/maptrek/MapTrek.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ synchronized public void optionallyCloseMapDatabase(UUID id) {
}
}

public void onMainActivityFinishing() {
public void onMainActivityFinished() {
logger.info("MainActivity finished");
optionallyCloseMapDatabase(null);
if (mWaypointDbDataSource != null) {
mWaypointDbDataSource.close();
Expand Down Expand Up @@ -630,7 +631,6 @@ public void uncaughtException(@NonNull final Thread thread, @NonNull final Throw
}

class ListeningToActivityCallbacks implements Application.ActivityLifecycleCallbacks {

@Override
public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
logger.warn("{} is onActivityCreated", activity.getLocalClassName());
Expand Down Expand Up @@ -666,10 +666,14 @@ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bun
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
logger.warn("{} is onActivityDestroyed", activity.getLocalClassName());
if (activity.isFinishing() && activity.getLocalClassName().equals(MainActivity.class.getSimpleName())) {
if (activity.isFinishing() && activity.getLocalClassName().equals(MainActivity.class.getSimpleName()))
mMainActivityExists = false;
onMainActivityFinishing();
}
}

@Override
public void onActivityPostDestroyed(@NonNull Activity activity) {
if (!mMainActivityExists && activity.getLocalClassName().equals(MainActivity.class.getSimpleName()))
onMainActivityFinished();
}
}
}

0 comments on commit cefca14

Please sign in to comment.