From ab90a3029d09116da068bfb3c67276807397fbf8 Mon Sep 17 00:00:00 2001 From: Mike Harris Date: Mon, 25 Sep 2017 23:02:54 -0700 Subject: [PATCH] Move Save/LoadFragment's layout ID inline and private. Fix the hack of using the layout resource ID as a save/load ID, and instead use a proper enum. --- .../dolphinemu/activities/EmulationActivity.java | 15 ++++++++++----- .../dolphinemu/fragments/LoadStateFragment.java | 3 +-- .../dolphinemu/fragments/SaveStateFragment.java | 3 +-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 10e803bc19..74c0eab9cb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -72,6 +72,11 @@ public final class EmulationActivity extends AppCompatActivity private static boolean mIsGameCubeGame; + private enum MenuType + { + SAVE, LOAD + } + /** * Handlers are a way to pass a message to an Activity telling it to do something * on the UI thread. This Handler responds to any message, even blank ones, by @@ -522,14 +527,14 @@ public final class EmulationActivity extends AppCompatActivity case MENU_ACTION_SAVE_ROOT: if (!mDeviceHasTouchScreen) { - showMenu(SaveStateFragment.FRAGMENT_ID); + showMenu(MenuType.SAVE); } return; case MENU_ACTION_LOAD_ROOT: if (!mDeviceHasTouchScreen) { - showMenu(LoadStateFragment.FRAGMENT_ID); + showMenu(MenuType.LOAD); } return; @@ -862,18 +867,18 @@ public final class EmulationActivity extends AppCompatActivity }); } - private void showMenu(int menuId) + private void showMenu(MenuType menuId) { Fragment fragment; switch (menuId) { - case SaveStateFragment.FRAGMENT_ID: + case SAVE: fragment = SaveStateFragment.newInstance(); mSubmenuFragmentTag = SaveStateFragment.FRAGMENT_TAG; break; - case LoadStateFragment.FRAGMENT_ID: + case LOAD: fragment = LoadStateFragment.newInstance(); mSubmenuFragmentTag = LoadStateFragment.FRAGMENT_TAG; break; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java index 95d5df94f5..894a4f76d3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java @@ -17,7 +17,6 @@ import org.dolphinemu.dolphinemu.activities.EmulationActivity; public final class LoadStateFragment extends Fragment implements View.OnClickListener { public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".load_state"; - public static final int FRAGMENT_ID = R.layout.fragment_state_load; private static SparseIntArray buttonsActionsMap = new SparseIntArray(); static { @@ -42,7 +41,7 @@ public final class LoadStateFragment extends Fragment implements View.OnClickLis @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(FRAGMENT_ID, container, false); + View rootView = inflater.inflate(R.layout.fragment_state_load, container, false); GridLayout grid = (GridLayout) rootView.findViewById(R.id.grid_state_slots); for (int childIndex = 0; childIndex < grid.getChildCount(); childIndex++) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java index f6d9482ebf..1d04b03a59 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java @@ -17,7 +17,6 @@ import org.dolphinemu.dolphinemu.activities.EmulationActivity; public final class SaveStateFragment extends Fragment implements View.OnClickListener { public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".save_state"; - public static final int FRAGMENT_ID = R.layout.fragment_state_save; private static SparseIntArray buttonsActionsMap = new SparseIntArray(); static { @@ -42,7 +41,7 @@ public final class SaveStateFragment extends Fragment implements View.OnClickLis @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(FRAGMENT_ID, container, false); + View rootView = inflater.inflate(R.layout.fragment_state_save, container, false); GridLayout grid = (GridLayout) rootView.findViewById(R.id.grid_state_slots); for (int childIndex = 0; childIndex < grid.getChildCount(); childIndex++)