mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
avoid ANR in MessageSelectorFragment.handleResendMessage
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
@@ -146,15 +147,22 @@ public abstract class MessageSelectorFragment
|
||||
|
||||
protected void handleResendMessage(final Set<DcMsg> dcMsgsSet) {
|
||||
int[] ids = DcMsg.msgSetToIds(dcMsgsSet);
|
||||
if (dcContext.resendMsgs(ids)) {
|
||||
actionMode.finish();
|
||||
Toast.makeText(getContext(), R.string.sending, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(dcContext.getLastError())
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
Util.runOnAnyBackgroundThread(() -> {
|
||||
boolean success = dcContext.resendMsgs(ids);
|
||||
Util.runOnMain(() -> {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null || activity.isFinishing()) return;
|
||||
if (success) {
|
||||
actionMode.finish();
|
||||
Toast.makeText(getContext(), R.string.sending, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
new AlertDialog.Builder(activity)
|
||||
.setMessage(dcContext.getLastError())
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user