Prevent crash when opting out of PIN after fragment is detached.
This commit is contained in:
parent
8ddec63e31
commit
45a3c44d0c
@ -200,7 +200,7 @@ public abstract class BaseSvrPinFragment<ViewModel extends BaseSvrPinViewModel>
|
||||
}
|
||||
|
||||
private void onPinSkipped() {
|
||||
PinOptOutDialog.show(requireContext(), false, () -> {
|
||||
PinOptOutDialog.show(requireContext(), getViewLifecycleOwner(), false, () -> {
|
||||
RegistrationUtil.maybeMarkRegistrationComplete();
|
||||
closeNavGraphBranch();
|
||||
});
|
||||
|
||||
@ -125,6 +125,6 @@ public final class SvrSplashFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void onPinSkipped() {
|
||||
PinOptOutDialog.show(requireContext(), false, () -> requireActivity().finish());
|
||||
PinOptOutDialog.show(requireContext(), getViewLifecycleOwner(), false, () -> requireActivity().finish());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
@ -21,7 +22,7 @@ public final class PinOptOutDialog {
|
||||
* @param rotateAep If true, this will rotate the AEP as part of the process of opting out. Only do this if the user has not enabled backups! If the user
|
||||
* has backups enabled, you should guide them through rotating the AEP first, and then call this with [rotateAep] = false.
|
||||
*/
|
||||
public static void show(@NonNull Context context, boolean rotateAep, @NonNull Runnable onSuccess) {
|
||||
public static void show(@NonNull Context context, @NonNull LifecycleOwner lifecycleOwner, boolean rotateAep, @NonNull Runnable onSuccess) {
|
||||
Log.i(TAG, "show()");
|
||||
AlertDialog dialog = new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.PinOptOutDialog_warning)
|
||||
@ -32,7 +33,7 @@ public final class PinOptOutDialog {
|
||||
d.dismiss();
|
||||
AlertDialog progress = SimpleProgressDialog.show(context);
|
||||
|
||||
SimpleTask.run(() -> {
|
||||
SimpleTask.run(lifecycleOwner.getLifecycle(), () -> {
|
||||
SvrRepository.optOutOfPin(rotateAep);
|
||||
return null;
|
||||
}, success -> {
|
||||
|
||||
@ -59,7 +59,7 @@ class AdvancedPinSettingsFragment : ComposeFragment() {
|
||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
viewModel.event.collectLatest {
|
||||
when (it) {
|
||||
AdvancedPinSettingsViewModel.Event.SHOW_BACKUPS_DISABLED_OPT_OUT_DIALOG -> PinOptOutDialog.show(requireContext(), true) {
|
||||
AdvancedPinSettingsViewModel.Event.SHOW_BACKUPS_DISABLED_OPT_OUT_DIALOG -> PinOptOutDialog.show(requireContext(), viewLifecycleOwner, true) {
|
||||
viewModel.onPinOptOutSuccess()
|
||||
displayOptOutSnackbar()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user