mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-18 18:26:27 +01:00
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.
This commit is contained in:
parent
94ed30b055
commit
d73100f0e4
@ -1,6 +1,5 @@
|
|||||||
package org.dolphinemu.dolphinemu.activities;
|
package org.dolphinemu.dolphinemu.activities;
|
||||||
|
|
||||||
import android.app.ActivityOptions;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -12,6 +11,7 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.IntDef;
|
import android.support.annotation.IntDef;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
@ -65,7 +65,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
private boolean mSystemUiVisible;
|
private boolean mSystemUiVisible;
|
||||||
private boolean mMenuVisible;
|
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
|
* 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("ScreenPath", screenshotPath);
|
||||||
launcher.putExtra("GridPosition", position);
|
launcher.putExtra("GridPosition", position);
|
||||||
|
|
||||||
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
|
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
|
||||||
activity,
|
activity,
|
||||||
sharedView,
|
sharedView,
|
||||||
"image_game_screenshot");
|
"image_game_screenshot");
|
||||||
@ -168,6 +168,15 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
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");
|
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
||||||
|
|
||||||
int themeId;
|
int themeId;
|
||||||
@ -210,7 +219,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTheme(themeId);
|
setTheme(themeId);
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
@ -221,12 +229,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
|
mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
|
||||||
.findFragmentById(R.id.fragment_emulation);
|
.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)
|
if (savedInstanceState == null)
|
||||||
{
|
{
|
||||||
// Picasso will take a while to load these big-ass screenshots. So don't run
|
// 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
|
@Override
|
||||||
public void onSuccess()
|
public void onSuccess()
|
||||||
{
|
{
|
||||||
startPostponedEnterTransition();
|
supportStartPostponedEnterTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError()
|
public void onError()
|
||||||
{
|
{
|
||||||
// Still have to do this, or else the app will crash.
|
// 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);
|
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
mIsGameCubeGame = Platform.fromNativeInt(NativeLibrary.GetPlatform(path)) == Platform.GAMECUBE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -400,7 +401,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
setResult(mPosition);
|
setResult(mPosition);
|
||||||
finishAfterTransition();
|
supportFinishAfterTransition();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
public boolean onCreateOptionsMenu(Menu menu)
|
public boolean onCreateOptionsMenu(Menu menu)
|
||||||
{
|
{
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// 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);
|
getMenuInflater().inflate(R.menu.menu_emulation, menu);
|
||||||
}
|
}
|
||||||
@ -598,7 +599,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
boolean[] enabledButtons = new boolean[14];
|
boolean[] enabledButtons = new boolean[14];
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.emulation_toggle_controls);
|
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++) {
|
for (int i = 0; i < enabledButtons.length; i++) {
|
||||||
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
|
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
|
||||||
}
|
}
|
||||||
@ -823,6 +824,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
|
|
||||||
public static boolean isGameCubeGame()
|
public static boolean isGameCubeGame()
|
||||||
{
|
{
|
||||||
return mIsGameCubeGame;
|
return sIsGameCubeGame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user