From 95539090ec8a7552aa219d858332942aed10f9ac Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 25 Nov 2013 09:55:46 -0500 Subject: [PATCH] [Android] Make CoreSelection and HistorySelection statically instantiable. Allows showing the dialogs without the need for an actual variable or ugly "new HistorySelection(fm, tag).show();" syntax. Also moved the else if for "Quit Retroarch" to the bottom of the if statements so its structured relative to the UI. --- .../com/retroarch/browser/CoreSelection.java | 10 ++++++++++ .../retroarch/browser/HistorySelection.java | 10 ++++++++++ .../browser/mainmenu/MainMenuFragment.java | 18 ++++++++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/android/phoenix/src/com/retroarch/browser/CoreSelection.java b/android/phoenix/src/com/retroarch/browser/CoreSelection.java index 9e2a5b18c1..f2097a6c57 100644 --- a/android/phoenix/src/com/retroarch/browser/CoreSelection.java +++ b/android/phoenix/src/com/retroarch/browser/CoreSelection.java @@ -27,6 +27,16 @@ public final class CoreSelection extends DialogFragment { private IconAdapter adapter; + /** + * Creates a statically instantiated instance of CoreSelection. + * + * @return a statically instantiated instance of CoreSelection. + */ + public static CoreSelection newInstance() + { + return new CoreSelection(); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/android/phoenix/src/com/retroarch/browser/HistorySelection.java b/android/phoenix/src/com/retroarch/browser/HistorySelection.java index 8b1da446e1..762f2af2bd 100644 --- a/android/phoenix/src/com/retroarch/browser/HistorySelection.java +++ b/android/phoenix/src/com/retroarch/browser/HistorySelection.java @@ -33,6 +33,16 @@ public final class HistorySelection extends DialogFragment private FragmentActivity ctx; private IconAdapter adapter; + /** + * Creates a statically instantiated instance of HistorySelection. + * + * @return a statically instantiated instance of HistorySelection. + */ + public static HistorySelection newInstance() + { + return new HistorySelection(); + } + @Override public void onCreate(Bundle savedInstanceState) { diff --git a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java index b88cf3e77e..cc29a10e4d 100644 --- a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java +++ b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java @@ -347,14 +347,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On // Load Core Preference else if (prefKey.equals("loadCorePref")) { - final CoreSelection coreSelection = new CoreSelection(); - coreSelection.show(getFragmentManager(), "core_selection"); - } - // Quit RetroArch preference - else if (prefKey.equals("quitRetroArch")) - { - // TODO - needs to close entire app gracefully - including - // NativeActivity if possible + CoreSelection.newInstance().show(getFragmentManager(), "core_selection"); } // Load ROM Preference else if (prefKey.equals("loadRomPref")) @@ -382,8 +375,13 @@ public final class MainMenuFragment extends PreferenceListFragment implements On // Load ROM (History) Preference else if (prefKey.equals("loadRomHistoryPref")) { - final HistorySelection historySelection = new HistorySelection(); - historySelection.show(getFragmentManager(), "history_selection"); + HistorySelection.newInstance().show(getFragmentManager(), "history_selection"); + } + // Quit RetroArch preference + else if (prefKey.equals("quitRetroArch")) + { + // TODO - needs to close entire app gracefully - including + // NativeActivity if possible } return true;