summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2023-03-16 17:12:58 +0100
committerGitHub <noreply@github.com>2023-03-16 17:12:58 +0100
commit6b545eaada79a45c3bd901bbc85f77f66e17bbf3 (patch)
tree61f2b86eacd3d1558d7ba4e06631d940bccc324d /Source
parentd623871f3e301aa3d85c59625b92b45c083aa9f1 (diff)
parentfe8be906f3f172028cf261eaf88423d75e2731d8 (diff)
Merge pull request #11659 from JosJuice/android-after-dirinit-runner-cleanup
Android: Clean up AfterDirectoryInitializationRunner
Diffstat (limited to 'Source')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java44
1 files changed, 13 insertions, 31 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java
index 651512bcb4..0312955156 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java
@@ -2,7 +2,7 @@
package org.dolphinemu.dolphinemu.utils;
-import androidx.core.app.ComponentActivity;
+import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization.DirectoryInitializationState;
@@ -12,25 +12,16 @@ public class AfterDirectoryInitializationRunner
private Observer<DirectoryInitializationState> mObserver;
/**
- * Executes a Runnable after directory initialization has finished.
+ * Executes a Runnable once directory initialization finishes.
*
- * If this is called when directory initialization already is done,
- * the Runnable will be executed immediately. If this is called before
- * directory initialization is done, the Runnable will be executed
- * after directory initialization finishes successfully, or never
- * in case directory initialization doesn't finish successfully.
+ * If this is called when directory initialization already has finished, the Runnable will
+ * be executed immediately. If this is called before directory initialization has finished,
+ * the Runnable will be executed after directory initialization finishes.
*
- * Calling this function multiple times per object is not supported.
- *
- * If abortOnFailure is true and external storage was not found, a message
- * will be shown to the user and the Runnable will not run. If it is false,
- * the attempt to run the Runnable will never be aborted, and the Runnable
- * is guaranteed to run if directory initialization ever finishes.
- *
- * If the passed-in activity gets destroyed before this operation finishes,
- * it will be automatically canceled.
+ * If the passed-in LifecycleOwner gets destroyed before this operation finishes,
+ * the operation will be automatically canceled.
*/
- public void runWithLifecycle(ComponentActivity activity, Runnable runnable)
+ public void runWithLifecycle(LifecycleOwner lifecycleOwner, Runnable runnable)
{
if (DirectoryInitialization.areDolphinDirectoriesReady())
{
@@ -39,25 +30,16 @@ public class AfterDirectoryInitializationRunner
else
{
mObserver = createObserver(runnable);
- DirectoryInitialization.getDolphinDirectoriesState().observe(activity, mObserver);
+ DirectoryInitialization.getDolphinDirectoriesState().observe(lifecycleOwner, mObserver);
}
}
/**
- * Executes a Runnable after directory initialization has finished.
- *
- * If this is called when directory initialization already is done,
- * the Runnable will be executed immediately. If this is called before
- * directory initialization is done, the Runnable will be executed
- * after directory initialization finishes successfully, or never
- * in case directory initialization doesn't finish successfully.
- *
- * Calling this function multiple times per object is not supported.
+ * Executes a Runnable once directory initialization finishes.
*
- * If abortOnFailure is true and external storage was not found, a message
- * will be shown to the user and the Runnable will not run. If it is false,
- * the attempt to run the Runnable will never be aborted, and the Runnable
- * is guaranteed to run if directory initialization ever finishes.
+ * If this is called when directory initialization already has finished, the Runnable will
+ * be executed immediately. If this is called before directory initialization has finished,
+ * the Runnable will be executed after directory initialization finishes.
*/
public void runWithoutLifecycle(Runnable runnable)
{