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 2753735200..27ec8cd794 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 @@ -42,6 +42,7 @@ import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.utils.Animations; import org.dolphinemu.dolphinemu.utils.Java_GCAdapter; import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter; +import org.dolphinemu.dolphinemu.utils.Log; import java.lang.annotation.Retention; import java.util.List; @@ -226,8 +227,17 @@ public final class EmulationActivity extends AppCompatActivity setContentView(R.layout.activity_emulation); mImageView = (ImageView) findViewById(R.id.image_screenshot); + + // Find or create the EmulationFragment mEmulationFragment = (EmulationFragment) getSupportFragmentManager() - .findFragmentById(R.id.fragment_emulation); + .findFragmentById(R.id.frame_emulation_fragment); + if (mEmulationFragment == null) + { + mEmulationFragment = EmulationFragment.newInstance(path); + getSupportFragmentManager().beginTransaction() + .add(R.id.frame_emulation_fragment, mEmulationFragment) + .commit(); + } if (savedInstanceState == null) { @@ -266,7 +276,6 @@ public final class EmulationActivity extends AppCompatActivity } }); - mEmulationFragment.setGamePath(path); mEmulationFragment.startEmulation(); } else diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index 0572d048f4..393790cf14 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -21,6 +21,8 @@ import org.dolphinemu.dolphinemu.utils.Log; public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback { + private static final String KEY_GAMEPATH = "gamepath"; + private SharedPreferences mPreferences; private Surface mSurface; @@ -32,6 +34,17 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C private String mGamePath; private final EmulationState mEmulationState = new EmulationState(); + public static EmulationFragment newInstance(String gamePath) + { + + Bundle args = new Bundle(); + args.putString(KEY_GAMEPATH, gamePath); + + EmulationFragment fragment = new EmulationFragment(); + fragment.setArguments(args); + return fragment; + } + @Override public void onAttach(Context context) { @@ -59,6 +72,8 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C setRetainInstance(true); mPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); + + mGamePath = getArguments().getString(KEY_GAMEPATH); } /** @@ -114,11 +129,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C super.onDetach(); } - public void setGamePath(String gamePath) - { - mGamePath = gamePath; - } - public void toggleInputOverlayVisibility() { SharedPreferences.Editor editor = mPreferences.edit(); diff --git a/Source/Android/app/src/main/res/layout-television/activity_emulation.xml b/Source/Android/app/src/main/res/layout-television/activity_emulation.xml index 3009f40e84..835af1b39b 100644 --- a/Source/Android/app/src/main/res/layout-television/activity_emulation.xml +++ b/Source/Android/app/src/main/res/layout-television/activity_emulation.xml @@ -5,9 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/frame_content"> - diff --git a/Source/Android/app/src/main/res/layout/activity_emulation.xml b/Source/Android/app/src/main/res/layout/activity_emulation.xml index 2562d5a44b..7ebaceee22 100644 --- a/Source/Android/app/src/main/res/layout/activity_emulation.xml +++ b/Source/Android/app/src/main/res/layout/activity_emulation.xml @@ -3,9 +3,8 @@ android:layout_height="match_parent" android:id="@+id/frame_content"> -