- if (savedInstanceState != null) {
- setFile((OCFile)savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE));
+ OCFile file = getFile();
+ if (savedInstanceState == null) {
+ if (file == null) {
+ throw new IllegalStateException("Instanced with a NULL OCFile");
+ }
+ if (mAccount == null) {
+ throw new IllegalStateException("Instanced with a NULL ownCloud Account");
+ }
+ if (!file.isDown()) {
+ throw new IllegalStateException("There is no local file to preview");
+ }
+
+ } else {
+ file = (OCFile)savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
+ setFile(file);