From 83f7be14c5ee91d43f3f0d9952de439c5961991d Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 2 Sep 2019 14:30:41 +0200 Subject: [PATCH] prevent npe Signed-off-by: tobiasKaminsky --- .../ui/preview/PreviewImageFragment.java | 18 ++++++++++++++---- src/main/res/values/strings.xml | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index d88cebcfbc..1ef9a9653a 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -694,10 +694,20 @@ public class PreviewImageFragment extends FileFragment implements Injectable { public void setErrorPreviewMessage() { try { if (getActivity() != null) { - Snackbar.make(mMultiView, R.string.resized_image_not_possible_download, Snackbar.LENGTH_INDEFINITE) - .setAction(R.string.common_yes, v -> - ((PreviewImageActivity) getActivity()) - .requestForDownload(getFile())).show(); + Snackbar.make(mMultiView, + R.string.resized_image_not_possible_download, + Snackbar.LENGTH_INDEFINITE) + .setAction(R.string.common_yes, v -> { + PreviewImageActivity activity = ((PreviewImageActivity) getActivity()); + if (activity != null) { + activity.requestForDownload(getFile()); + } else { + Snackbar.make(mMultiView, + getResources().getString(R.string.could_not_download_image), + Snackbar.LENGTH_INDEFINITE).show(); + } + } + ).show(); } else { Snackbar.make(mMultiView, R.string.resized_image_not_possible, Snackbar.LENGTH_INDEFINITE).show(); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 504ecc58ec..399c7909d0 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -901,4 +901,5 @@ Copied to clipboard Download latest dev version Changelog dev version + Could not download full image