mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Remove redundant pause/unpause code
This commit is contained in:
parent
1fdabc7481
commit
6b68b76aed
@ -71,9 +71,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||
|
||||
private Settings mSettings;
|
||||
|
||||
private MenuItem mPauseEmulationButton;
|
||||
private MenuItem mUnpauseEmulationButton;
|
||||
|
||||
private boolean mDeviceHasTouchScreen;
|
||||
private boolean mMenuVisible;
|
||||
|
||||
@ -544,13 +541,11 @@ public final class EmulationActivity extends AppCompatActivity
|
||||
case MENU_ACTION_PAUSE_EMULATION:
|
||||
sUserPausedEmulation = true;
|
||||
NativeLibrary.PauseEmulation();
|
||||
showUnpauseEmulationButton();
|
||||
return;
|
||||
|
||||
case MENU_ACTION_UNPAUSE_EMULATION:
|
||||
sUserPausedEmulation = false;
|
||||
NativeLibrary.UnPauseEmulation();
|
||||
showPauseEmulationButton();
|
||||
return;
|
||||
|
||||
// Screenshot capturing
|
||||
@ -653,28 +648,11 @@ public final class EmulationActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void showPauseEmulationButton()
|
||||
{
|
||||
mUnpauseEmulationButton.setVisible(false);
|
||||
mPauseEmulationButton.setVisible(true);
|
||||
}
|
||||
|
||||
private void showUnpauseEmulationButton()
|
||||
{
|
||||
mPauseEmulationButton.setVisible(false);
|
||||
mUnpauseEmulationButton.setVisible(true);
|
||||
}
|
||||
|
||||
public static boolean getHasUserPausedEmulation()
|
||||
{
|
||||
return sUserPausedEmulation;
|
||||
}
|
||||
|
||||
public static void setHasUserPausedEmulation(boolean value)
|
||||
{
|
||||
sUserPausedEmulation = value;
|
||||
}
|
||||
|
||||
private void toggleJoystickRelCenter(boolean state)
|
||||
{
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
@ -690,7 +668,6 @@ public final class EmulationActivity extends AppCompatActivity
|
||||
Rumble.setPhoneVibrator(state, this);
|
||||
}
|
||||
|
||||
|
||||
private void editControlsPlacement()
|
||||
{
|
||||
if (mEmulationFragment.isConfiguringControls())
|
||||
|
@ -72,10 +72,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||
mPauseEmulation = options.findViewById(R.id.menu_pause_emulation);
|
||||
mUnpauseEmulation = options.findViewById(R.id.menu_unpause_emulation);
|
||||
|
||||
if (EmulationActivity.getHasUserPausedEmulation())
|
||||
{
|
||||
showUnpauseEmulationButton();
|
||||
}
|
||||
updatePauseUnpauseVisibility();
|
||||
|
||||
boolean enableSaveStates = ((EmulationActivity) getActivity()).getSettings()
|
||||
.getSection(SettingsFile.FILE_NAME_DOLPHIN, Settings.SECTION_INI_CORE)
|
||||
@ -126,16 +123,12 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void showPauseEmulationButton()
|
||||
private void updatePauseUnpauseVisibility()
|
||||
{
|
||||
mUnpauseEmulation.setVisibility(View.GONE);
|
||||
mPauseEmulation.setVisibility(View.VISIBLE);
|
||||
}
|
||||
boolean paused = EmulationActivity.getHasUserPausedEmulation();
|
||||
|
||||
private void showUnpauseEmulationButton()
|
||||
{
|
||||
mPauseEmulation.setVisibility(View.GONE);
|
||||
mUnpauseEmulation.setVisibility(View.VISIBLE);
|
||||
mUnpauseEmulation.setVisibility(paused ? View.VISIBLE : View.GONE);
|
||||
mPauseEmulation.setVisibility(paused ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WrongConstant")
|
||||
@ -145,19 +138,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||
int action = buttonsActionsMap.get(button.getId());
|
||||
EmulationActivity activity = (EmulationActivity) requireActivity();
|
||||
|
||||
if (action == EmulationActivity.MENU_ACTION_PAUSE_EMULATION)
|
||||
{
|
||||
EmulationActivity.setHasUserPausedEmulation(true);
|
||||
NativeLibrary.PauseEmulation();
|
||||
showUnpauseEmulationButton();
|
||||
}
|
||||
else if (action == EmulationActivity.MENU_ACTION_UNPAUSE_EMULATION)
|
||||
{
|
||||
EmulationActivity.setHasUserPausedEmulation(false);
|
||||
NativeLibrary.UnPauseEmulation();
|
||||
showPauseEmulationButton();
|
||||
}
|
||||
else if (action == EmulationActivity.MENU_ACTION_OVERLAY_CONTROLS)
|
||||
if (action == EmulationActivity.MENU_ACTION_OVERLAY_CONTROLS)
|
||||
{
|
||||
// We could use the button parameter as the anchor here, but this often results in a tiny menu
|
||||
// (because the button often is in the middle of the screen), so let's use mTitleText instead
|
||||
@ -167,5 +148,11 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
|
||||
{
|
||||
activity.handleMenuAction(action);
|
||||
}
|
||||
|
||||
if (action == EmulationActivity.MENU_ACTION_PAUSE_EMULATION ||
|
||||
action == EmulationActivity.MENU_ACTION_UNPAUSE_EMULATION)
|
||||
{
|
||||
updatePauseUnpauseVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user