Fix case where dialog could be shown after user leaves fragment.
This commit is contained in:
parent
b5cc570363
commit
88074134af
2 changed files with 35 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
package org.thoughtcrime.securesms.conversation.mutiselect.forward
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
|
@ -206,6 +207,11 @@ class MultiselectForwardFragment :
|
|||
handler?.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
dismissibleDialog?.dismissNow()
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
private fun displayFirstSendConfirmation() {
|
||||
SignalStore.tooltips().markMultiForwardDialogSeen()
|
||||
|
||||
|
|
|
@ -68,26 +68,43 @@ public final class SimpleProgressDialog {
|
|||
|
||||
ThreadUtil.runOnMainDelayed(showRunnable, delayMs);
|
||||
|
||||
return () -> {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
long beenShowingForMs = System.currentTimeMillis() - shownAt.get();
|
||||
long remainingTimeMs = minimumShowTimeMs - beenShowingForMs;
|
||||
return new DismissibleDialog() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
long beenShowingForMs = System.currentTimeMillis() - shownAt.get();
|
||||
long remainingTimeMs = minimumShowTimeMs - beenShowingForMs;
|
||||
|
||||
if (remainingTimeMs > 0) {
|
||||
ThreadUtil.runOnMainDelayed(alertDialog::dismiss, remainingTimeMs);
|
||||
} else {
|
||||
if (remainingTimeMs > 0) {
|
||||
ThreadUtil.runOnMainDelayed(alertDialog::dismiss, remainingTimeMs);
|
||||
} else {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissNow() {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface DismissibleDialog {
|
||||
@AnyThread
|
||||
void dismiss();
|
||||
|
||||
@AnyThread
|
||||
void dismissNow();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue