1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 12:32:31 +01:00

Add close() method to NewPipeDatabase

This commit is contained in:
TobiGr 2021-07-10 14:46:51 +02:00
parent 7c3f5a62c5
commit 9ca2691a2c
2 changed files with 12 additions and 1 deletions

View File

@ -51,4 +51,15 @@ public final class NewPipeDatabase {
throw new RuntimeException("Checkpoint was blocked from completing"); throw new RuntimeException("Checkpoint was blocked from completing");
} }
} }
public static void close() {
if (databaseInstance != null) {
synchronized (NewPipeDatabase.class) {
if (databaseInstance != null) {
databaseInstance.close();
databaseInstance = null;
}
}
}
}
} }

View File

@ -609,7 +609,7 @@ public final class NavigationHelper {
* @param activity the activity to finish * @param activity the activity to finish
*/ */
public static void restartApp(final Activity activity) { public static void restartApp(final Activity activity) {
NewPipeDatabase.getInstance(activity).close(); NewPipeDatabase.close();
activity.finishAffinity(); activity.finishAffinity();
final Intent intent = new Intent(activity, MainActivity.class); final Intent intent = new Intent(activity, MainActivity.class);
activity.startActivity(intent); activity.startActivity(intent);