Improved share error handling

pull/209/head
M66B 2 years ago
parent 2a4b220b7b
commit 2b7b1c83b8

@ -349,8 +349,12 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
}
private void onShare(EntityAttachment attachment) {
String title = (attachment.name == null ? attachment.cid : attachment.name);
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), title);
try {
String title = (attachment.name == null ? attachment.cid : attachment.name);
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), title);
} catch (Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}
private void onDownload(EntityAttachment attachment) {

@ -210,7 +210,11 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
EntityAttachment attachment = items.get(pos);
if (attachment.available)
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), attachment.name);
try {
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), attachment.name);
} catch (Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
else {
if (attachment.progress == null) {
Bundle args = new Bundle();

@ -866,12 +866,8 @@ public class Helper {
static void share(Context context, File file, String type, String name) {
// https://developer.android.com/reference/androidx/core/content/FileProvider
try {
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
share(context, uri, type, name);
} catch (Throwable ex) {
Log.e(ex);
}
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
share(context, uri, type, name);
}
static void share(Context context, Uri uri, String type, String name) {

Loading…
Cancel
Save