浏览代码

prevent NPE

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 年之前
父节点
当前提交
b31cee531b
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      src/main/java/com/owncloud/android/ui/asynctasks/LoadUrlTask.java

+ 8 - 4
src/main/java/com/owncloud/android/ui/asynctasks/LoadUrlTask.java

@@ -45,14 +45,18 @@ public class LoadUrlTask extends AsyncTask<String, Void, String> {
 
     @Override
     protected String doInBackground(String... fileId) {
-        if (editorWebViewWeakReference.get() == null) {
+        final EditorWebView editorWebView = editorWebViewWeakReference.get();
+
+        if (editorWebView == null) {
             return "";
         }
 
-        RemoteOperationResult result = null;
-        if (editorWebViewWeakReference.get() instanceof RichDocumentsEditorWebView) {
+        RemoteOperationResult result;
+
+
+        if (editorWebView instanceof RichDocumentsEditorWebView) {
             result = new RichDocumentsUrlOperation(fileId[0]).execute(account, editorWebViewWeakReference.get());
-        } else if (editorWebViewWeakReference.get() instanceof TextEditorWebView) {
+        } else if (editorWebView instanceof TextEditorWebView) {
             result = new DirectEditingOpenFileRemoteOperation(fileId[0], TEXT)
                 .execute(account, editorWebViewWeakReference.get());
         } else {