Delegate fragment back to activity

pull/208/head
M66B 3 years ago
parent c072793b58
commit 71425ade16

@ -770,6 +770,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
finish();
}
public void onBackPressedFragment() {
performBack();
}
@Override
public boolean shouldUpRecreateTask(Intent targetIntent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {

@ -695,16 +695,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
});
getSupportFragmentManager().addOnBackStackChangedListener(this);
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (Helper.isKeyboardVisible(view))
Helper.hideKeyboard(view);
else
onExit();
}
});
getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
// Initialize
@ -727,6 +718,21 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Shortcuts.update(this, this);
}
@Override
public void onBackPressedFragment() {
backPressedCallback.handleOnBackPressed();
}
private OnBackPressedCallback backPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (Helper.isKeyboardVisible(view))
Helper.hideKeyboard(view);
else
onExit();
}
};
private void init() {
Bundle args = new Bundle();

@ -7414,6 +7414,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
handleExit();
FragmentActivity activity = getActivity();
if (activity instanceof ActivityBase)
((ActivityBase) activity).onBackPressedFragment();
else
finish();
}
};

Loading…
Cancel
Save