diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index 6843730d72..91744124cf 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -120,7 +120,8 @@ public class FileDataStorageManager { } - public OCFile getFileById(long id) { + public @Nullable + OCFile getFileById(long id) { Cursor c = getFileCursorForValue(ProviderTableMeta._ID, String.valueOf(id)); OCFile file = null; if (c.moveToFirst()) { diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 50b4a22f60..e71bf66dab 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1545,7 +1545,7 @@ public class FileDisplayActivity extends HookActivity if (mWaitingToPreview != null && getStorageManager() != null) { // update the file mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId()); - if (!mWaitingToPreview.isDown()) { + if (mWaitingToPreview != null && !mWaitingToPreview.isDown()) { requestForDownload(); } }