summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorMike Harris <atarimike@gmail.com>2017-10-10 23:51:42 -0700
committerMike Harris <atarimike@gmail.com>2017-10-16 20:36:12 -0700
commitd73100f0e41231da807be11a107801488eb6bff4 (patch)
treeca05499eaa73b38e45c204487264b9f32c2e83f5 /Source/Android/app/src/main/java
parent94ed30b0550f29b58774fcd28aa98d28562be985 (diff)
Minor cleanup in EmulationActivity.
Move the parameter extraction earlier on in onCreate. Mostly this moves setting sIsGameCubeGame to before setContentView, which means EmulationFragment will always see it in a consistent state. Previously, there was a race, which mean the controller overlay would randomly be Wii controls for a GameCube game (since the default is false). Use the correct support version of things, ActivityOptionsCompat and transitions Rename static var mIsGameCubeGame to sIsGameCubeGame. s is static, m is member.
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java39
1 files changed, 20 insertions, 19 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 f02a0e3b3b..2753735200 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
@@ -1,6 +1,5 @@
package org.dolphinemu.dolphinemu.activities;
-import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -12,6 +11,7 @@ import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.annotation.IntDef;
+import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
@@ -65,7 +65,7 @@ public final class EmulationActivity extends AppCompatActivity
private boolean mSystemUiVisible;
private boolean mMenuVisible;
- private static boolean mIsGameCubeGame;
+ private static boolean sIsGameCubeGame;
/**
* Handlers are a way to pass a message to an Activity telling it to do something
@@ -155,7 +155,7 @@ public final class EmulationActivity extends AppCompatActivity
launcher.putExtra("ScreenPath", screenshotPath);
launcher.putExtra("GridPosition", position);
- ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
+ ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
activity,
sharedView,
"image_game_screenshot");
@@ -168,6 +168,15 @@ public final class EmulationActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState)
{
+ super.onCreate(savedInstanceState);
+
+ // Get params we were passed
+ Intent gameToEmulate = getIntent();
+ String path = gameToEmulate.getStringExtra("SelectedGame");
+ sIsGameCubeGame = Platform.fromNativeInt(NativeLibrary.GetPlatform(path)) == Platform.GAMECUBE;
+ mSelectedTitle = gameToEmulate.getStringExtra("SelectedTitle");
+ mScreenPath = gameToEmulate.getStringExtra("ScreenPath");
+ mPosition = gameToEmulate.getIntExtra("GridPosition", -1);
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
int themeId;
@@ -210,23 +219,16 @@ public final class EmulationActivity extends AppCompatActivity
}
setTheme(themeId);
- super.onCreate(savedInstanceState);
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
-
+
setContentView(R.layout.activity_emulation);
mImageView = (ImageView) findViewById(R.id.image_screenshot);
mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
.findFragmentById(R.id.fragment_emulation);
- Intent gameToEmulate = getIntent();
- String path = gameToEmulate.getStringExtra("SelectedGame");
- mSelectedTitle = gameToEmulate.getStringExtra("SelectedTitle");
- mScreenPath = gameToEmulate.getStringExtra("ScreenPath");
- mPosition = gameToEmulate.getIntExtra("GridPosition", -1);
-
if (savedInstanceState == null)
{
// Picasso will take a while to load these big-ass screenshots. So don't run
@@ -242,14 +244,14 @@ public final class EmulationActivity extends AppCompatActivity
@Override
public void onSuccess()
{
- startPostponedEnterTransition();
+ supportStartPostponedEnterTransition();
}
@Override
public void onError()
{
// Still have to do this, or else the app will crash.
- startPostponedEnterTransition();
+ supportStartPostponedEnterTransition();
}
});
@@ -279,7 +281,6 @@ public final class EmulationActivity extends AppCompatActivity
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- mIsGameCubeGame = Platform.fromNativeInt(NativeLibrary.GetPlatform(path)) == Platform.GAMECUBE;
}
@Override
@@ -400,15 +401,15 @@ public final class EmulationActivity extends AppCompatActivity
public void run()
{
setResult(mPosition);
- finishAfterTransition();
+ supportFinishAfterTransition();
}
};
-
+
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
- if (mIsGameCubeGame)
+ if (sIsGameCubeGame)
{
getMenuInflater().inflate(R.menu.menu_emulation, menu);
}
@@ -598,7 +599,7 @@ public final class EmulationActivity extends AppCompatActivity
boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_toggle_controls);
- if (mIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0) {
+ if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0) {
for (int i = 0; i < enabledButtons.length; i++) {
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
}
@@ -823,6 +824,6 @@ public final class EmulationActivity extends AppCompatActivity
public static boolean isGameCubeGame()
{
- return mIsGameCubeGame;
+ return sIsGameCubeGame;
}
}