prevent npe

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-09-02 14:30:41 +02:00
parent f284d3bcb6
commit 83f7be14c5
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 15 additions and 4 deletions

View file

@ -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();
}

View file

@ -901,4 +901,5 @@
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="download_latest_dev_version">Download latest dev version</string>
<string name="changelog_dev_version">Changelog dev version</string>
<string name="could_not_download_image">Could not download full image</string>
</resources>