mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
Android: Use LifecycleOwner instead of subtype
This commit is contained in:
parent
846f5f6671
commit
fe8be906f3
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package org.dolphinemu.dolphinemu.utils;
|
package org.dolphinemu.dolphinemu.utils;
|
||||||
|
|
||||||
import androidx.core.app.ComponentActivity;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization.DirectoryInitializationState;
|
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization.DirectoryInitializationState;
|
||||||
@ -18,10 +18,10 @@ public class AfterDirectoryInitializationRunner
|
|||||||
* be executed immediately. If this is called before directory initialization has finished,
|
* be executed immediately. If this is called before directory initialization has finished,
|
||||||
* the Runnable will be executed after directory initialization finishes.
|
* the Runnable will be executed after directory initialization finishes.
|
||||||
*
|
*
|
||||||
* If the passed-in activity gets destroyed before this operation finishes,
|
* If the passed-in LifecycleOwner gets destroyed before this operation finishes,
|
||||||
* it will be automatically canceled.
|
* the operation will be automatically canceled.
|
||||||
*/
|
*/
|
||||||
public void runWithLifecycle(ComponentActivity activity, Runnable runnable)
|
public void runWithLifecycle(LifecycleOwner lifecycleOwner, Runnable runnable)
|
||||||
{
|
{
|
||||||
if (DirectoryInitialization.areDolphinDirectoriesReady())
|
if (DirectoryInitialization.areDolphinDirectoriesReady())
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ public class AfterDirectoryInitializationRunner
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mObserver = createObserver(runnable);
|
mObserver = createObserver(runnable);
|
||||||
DirectoryInitialization.getDolphinDirectoriesState().observe(activity, mObserver);
|
DirectoryInitialization.getDolphinDirectoriesState().observe(lifecycleOwner, mObserver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user