Android: Refactor MainActivity, add forEachPlatformGamesView
This commit is contained in:
parent
5e4c6d42a1
commit
3a8793f93f
|
@ -28,6 +28,7 @@ import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
|
||||||
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
||||||
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
||||||
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
|
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.Action1;
|
||||||
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||||
|
@ -90,7 +91,7 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||||
|
|
||||||
// In case the user changed a setting that affects how games are displayed,
|
// In case the user changed a setting that affects how games are displayed,
|
||||||
// such as system language, cover downloading...
|
// such as system language, cover downloading...
|
||||||
refetchMetadata();
|
forEachPlatformGamesView(PlatformGamesView::refetchMetadata);
|
||||||
|
|
||||||
if (sShouldRescanLibrary)
|
if (sShouldRescanLibrary)
|
||||||
{
|
{
|
||||||
|
@ -266,26 +267,20 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||||
return mPresenter.handleOptionSelection(item.getItemId(), this);
|
return mPresenter.handleOptionSelection(item.getItemId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showGames()
|
public void showGames()
|
||||||
{
|
{
|
||||||
for (Platform platform : Platform.values())
|
forEachPlatformGamesView(PlatformGamesView::showGames);
|
||||||
{
|
|
||||||
PlatformGamesView fragment = getPlatformGamesView(platform);
|
|
||||||
if (fragment != null)
|
|
||||||
{
|
|
||||||
fragment.showGames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refetchMetadata()
|
private void forEachPlatformGamesView(Action1<PlatformGamesView> action)
|
||||||
{
|
{
|
||||||
for (Platform platform : Platform.values())
|
for (Platform platform : Platform.values())
|
||||||
{
|
{
|
||||||
PlatformGamesView fragment = getPlatformGamesView(platform);
|
PlatformGamesView fragment = getPlatformGamesView(platform);
|
||||||
if (fragment != null)
|
if (fragment != null)
|
||||||
{
|
{
|
||||||
fragment.refetchMetadata();
|
action.call(fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue