Merge pull request #12572 from JosJuice/android-menu-init-guard

Android: Don't check Wii Menu version before directory initialization
This commit is contained in:
Mai 2024-02-11 13:51:30 -05:00 committed by GitHub
commit 9b3fdfb37b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 6 deletions

View File

@ -47,6 +47,8 @@ class MainActivity : AppCompatActivity(), MainView, OnRefreshListener, ThemeProv
private lateinit var binding: ActivityMainBinding
private lateinit var menu: Menu
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen().setKeepOnScreenCondition { !DirectoryInitialization.areDolphinDirectoriesReady() }
@ -121,15 +123,26 @@ class MainActivity : AppCompatActivity(), MainView, OnRefreshListener, ThemeProv
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_game_grid, menu)
if (WiiUtils.isSystemMenuInstalled()) {
val resId =
if (WiiUtils.isSystemMenuvWii()) R.string.grid_menu_load_vwii_system_menu_installed else R.string.grid_menu_load_wii_system_menu_installed
menu.findItem(R.id.menu_load_wii_system_menu).title =
getString(resId, WiiUtils.getSystemMenuVersion())
}
this.menu = menu
return true
}
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
AfterDirectoryInitializationRunner().runWithLifecycle(this) {
if (WiiUtils.isSystemMenuInstalled()) {
val resId =
if (WiiUtils.isSystemMenuvWii()) R.string.grid_menu_load_vwii_system_menu_installed else R.string.grid_menu_load_wii_system_menu_installed
// If this callback ends up running after another call to onCreateOptionsMenu,
// we need to use the new Menu passed to the latest call of onCreateOptionsMenu.
// Therefore, we use a field here instead of the onPrepareOptionsMenu argument.
this.menu.findItem(R.id.menu_load_wii_system_menu).title =
getString(resId, WiiUtils.getSystemMenuVersion())
}
}
return super.onPrepareOptionsMenu(menu)
}
/**
* MainView
*/