Skip to content

Commit

Permalink
Merge pull request #182 from JosJuice/settings-lifecycle
Browse files Browse the repository at this point in the history
Fix SettingsActivity back stack behavior after stop+start
  • Loading branch information
SachinVin authored Sep 11, 2021
2 parents bed6a4f + 1ba43c7 commit 6f6f9a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ protected void onStop() {
getWindowManager().getDefaultDisplay().getRotation());
}

@Override
public void onBackPressed() {
mPresenter.onBackPressed();
}


@Override
public void showSettingsFragment(String menuTag, boolean addToStack, String gameID) {
if (!addToStack && getFragment() != null) {
return;
}

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

if (addToStack) {
Expand All @@ -116,7 +114,6 @@ public void showSettingsFragment(String menuTag, boolean addToStack, String game
}

transaction.addToBackStack(null);
mPresenter.addToStack();
}
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID), FRAGMENT_TAG);

Expand Down Expand Up @@ -207,11 +204,6 @@ public void showToastMessage(String message, boolean is_long) {
Toast.makeText(this, message, is_long ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
}

@Override
public void popBackStack() {
getSupportFragmentManager().popBackStackImmediate();
}

@Override
public void onSettingChanged() {
mPresenter.onSettingChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public final class SettingsActivityPresenter {

private Settings mSettings = new Settings();

private int mStackCount;

private boolean mShouldSave;

private DirectoryStateReceiver directoryStateReceiver;
Expand All @@ -45,7 +43,6 @@ public void onCreate(Bundle savedInstanceState, String menuTag, String gameId) {
}

public void onStart() {
this.mStackCount = 0;
prepareCitraDirectoriesIfNeeded();
}

Expand Down Expand Up @@ -117,19 +114,6 @@ public void onStop(boolean finishing) {
NativeLibrary.ReloadSettings();
}

public void addToStack() {
mStackCount++;
}

public void onBackPressed() {
if (mStackCount > 0) {
mView.popBackStack();
mStackCount--;
} else {
mView.finish();
}
}

public void onSettingChanged() {
mShouldSave = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public interface SettingsActivityView {
*/
void showToastMessage(String message, boolean is_long);

/**
* Show the previous fragment.
*/
void popBackStack();

/**
* End the activity.
*/
Expand Down

0 comments on commit 6f6f9a0

Please sign in to comment.