Prevent crash

This commit is contained in:
M66B
2020-10-29 08:32:23 +01:00
parent 7aea1370ca
commit 26496c1341
4 changed files with 43 additions and 22 deletions

View File

@@ -4775,22 +4775,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message.raw == null || !message.raw) {
properties.setValue("raw_send", message.id, true);
rawDownload(message);
} else {
File file = message.getRawFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_STREAM, uri);
send.setType("message/rfc822");
send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else
try {
File file = message.getRawFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_STREAM, uri);
send.setType("message/rfc822");
send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(send);
} catch (ActivityNotFoundException ex) {
Log.w(ex);
ToastEx.makeText(context, context.getString(R.string.title_no_viewer, send), Toast.LENGTH_LONG).show();
} catch (Throwable ex) {
// java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}
}
private void rawDownload(TupleMessageEx message) {