forked from dolphin-emu/dolphin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dolphin-emu#8190 from JosJuice/android-init
Android: Call UICommon::Init at app start instead of emulation start
- Loading branch information
Showing
10 changed files
with
127 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...app/src/main/java/org/dolphinemu/dolphinemu/utils/AfterDirectoryInitializationRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.dolphinemu.dolphinemu.utils; | ||
|
||
import android.content.Context; | ||
import android.content.IntentFilter; | ||
import android.support.v4.content.LocalBroadcastManager; | ||
|
||
public class AfterDirectoryInitializationRunner | ||
{ | ||
private DirectoryStateReceiver directoryStateReceiver; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
public void run(Context context, Runnable runnable) | ||
{ | ||
if (!DirectoryInitialization.areDolphinDirectoriesReady()) | ||
{ | ||
// Wait for directories to get initialized | ||
IntentFilter statusIntentFilter = new IntentFilter( | ||
DirectoryInitialization.BROADCAST_ACTION); | ||
|
||
directoryStateReceiver = new DirectoryStateReceiver(directoryInitializationState -> | ||
{ | ||
if (directoryInitializationState == | ||
DirectoryInitialization.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED) | ||
{ | ||
LocalBroadcastManager.getInstance(context).unregisterReceiver(directoryStateReceiver); | ||
directoryStateReceiver = null; | ||
runnable.run(); | ||
} | ||
}); | ||
// Registers the DirectoryStateReceiver and its intent filters | ||
LocalBroadcastManager.getInstance(context).registerReceiver( | ||
directoryStateReceiver, | ||
statusIntentFilter); | ||
} | ||
else | ||
{ | ||
runnable.run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.