mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 16:59:18 +01:00
Merge pull request #9009 from JosJuice/android-settings-recreation
Android: Fix SettingsActivity lifecycle management
This commit is contained in:
commit
5ec65a20d6
@ -111,16 +111,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||||||
mPresenter.onStop(isFinishing());
|
mPresenter.onStop(isFinishing());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed()
|
|
||||||
{
|
|
||||||
mPresenter.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
|
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
|
||||||
String gameID)
|
String gameID)
|
||||||
{
|
{
|
||||||
|
if (!addToStack && getFragment() != null)
|
||||||
|
return;
|
||||||
|
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
if (addToStack)
|
if (addToStack)
|
||||||
@ -135,7 +132,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||||||
}
|
}
|
||||||
|
|
||||||
transaction.addToBackStack(null);
|
transaction.addToBackStack(null);
|
||||||
mPresenter.addToStack();
|
|
||||||
}
|
}
|
||||||
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras),
|
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras),
|
||||||
FRAGMENT_TAG);
|
FRAGMENT_TAG);
|
||||||
@ -277,12 +273,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void popBackStack()
|
|
||||||
{
|
|
||||||
getSupportFragmentManager().popBackStackImmediate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingChanged(String key)
|
public void onSettingChanged(String key)
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,6 @@ public final class SettingsActivityPresenter
|
|||||||
|
|
||||||
private Settings mSettings;
|
private Settings mSettings;
|
||||||
|
|
||||||
private int mStackCount;
|
|
||||||
|
|
||||||
private boolean mShouldSave;
|
private boolean mShouldSave;
|
||||||
|
|
||||||
private DirectoryStateReceiver directoryStateReceiver;
|
private DirectoryStateReceiver directoryStateReceiver;
|
||||||
@ -43,16 +41,11 @@ public final class SettingsActivityPresenter
|
|||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState, MenuTag menuTag, String gameId, Context context)
|
public void onCreate(Bundle savedInstanceState, MenuTag menuTag, String gameId, Context context)
|
||||||
{
|
{
|
||||||
if (savedInstanceState == null)
|
this.menuTag = menuTag;
|
||||||
{
|
this.gameId = gameId;
|
||||||
this.menuTag = menuTag;
|
this.context = context;
|
||||||
this.gameId = gameId;
|
|
||||||
this.context = context;
|
mShouldSave = savedInstanceState != null && savedInstanceState.getBoolean(KEY_SHOULD_SAVE);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mShouldSave = savedInstanceState.getBoolean(KEY_SHOULD_SAVE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStart()
|
public void onStart()
|
||||||
@ -148,24 +141,6 @@ public final class SettingsActivityPresenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToStack()
|
|
||||||
{
|
|
||||||
mStackCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onBackPressed()
|
|
||||||
{
|
|
||||||
if (mStackCount > 0)
|
|
||||||
{
|
|
||||||
mView.popBackStack();
|
|
||||||
mStackCount--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mView.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean handleOptionsItem(int itemId)
|
public boolean handleOptionsItem(int itemId)
|
||||||
{
|
{
|
||||||
switch (itemId)
|
switch (itemId)
|
||||||
|
@ -47,11 +47,6 @@ public interface SettingsActivityView
|
|||||||
*/
|
*/
|
||||||
void showToastMessage(String message);
|
void showToastMessage(String message);
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the previous fragment.
|
|
||||||
*/
|
|
||||||
void popBackStack();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End the activity.
|
* End the activity.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user