Android: Fix SettingsActivity back stack behavior after stop+start
Fixes the behavior where the settings activity would go back to the top-level menu after switching to a different app and back.
This commit is contained in:
parent
c727f03590
commit
05e49b13ef
|
@ -108,16 +108,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
mPresenter.onStop(isFinishing());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
mPresenter.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
|
||||
String gameID)
|
||||
{
|
||||
if (!addToStack && getFragment() != null)
|
||||
return;
|
||||
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
if (addToStack)
|
||||
|
@ -132,7 +129,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
}
|
||||
|
||||
transaction.addToBackStack(null);
|
||||
mPresenter.addToStack();
|
||||
}
|
||||
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras),
|
||||
FRAGMENT_TAG);
|
||||
|
@ -279,12 +275,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popBackStack()
|
||||
{
|
||||
getSupportFragmentManager().popBackStackImmediate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSettingChanged(String key)
|
||||
{
|
||||
|
|
|
@ -23,8 +23,6 @@ public final class SettingsActivityPresenter
|
|||
|
||||
private Settings mSettings = new Settings();
|
||||
|
||||
private int mStackCount;
|
||||
|
||||
private boolean mShouldSave;
|
||||
|
||||
private DirectoryStateReceiver directoryStateReceiver;
|
||||
|
@ -147,24 +145,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)
|
||||
{
|
||||
switch (itemId)
|
||||
|
|
|
@ -56,11 +56,6 @@ public interface SettingsActivityView
|
|||
*/
|
||||
void showToastMessage(String message);
|
||||
|
||||
/**
|
||||
* Show the previous fragment.
|
||||
*/
|
||||
void popBackStack();
|
||||
|
||||
/**
|
||||
* End the activity.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue