Skip to content

Commit

Permalink
Reload rich document edition on reload event from webview (triggered …
Browse files Browse the repository at this point in the history
…on session expiration)
  • Loading branch information
nicofrand committed Apr 9, 2024
1 parent e416eef commit 70b1597
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.SyncedFolderProvider;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.ui.asynctasks.TextEditorLoadUrlTask;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.WebViewUtil;
Expand Down Expand Up @@ -99,6 +100,23 @@ public void closeView() {
finish();
}

public void reload() {
if (getWebView().getVisibility() != View.VISIBLE) {
return;
}

Optional<User> user = getUser();
if (!user.isPresent()) {
return;
}

OCFile file = getFile();
if (file != null) {
TextEditorLoadUrlTask task = new TextEditorLoadUrlTask(this, user.get(), file, editorUtils);
task.execute();
}
}

@Override
protected void bindView() {
binding = RichdocumentsWebviewBinding.inflate(getLayoutInflater());
Expand Down Expand Up @@ -281,6 +299,11 @@ public void share() {
public void loaded() {
runOnUiThread(EditorWebView.this::hideLoading);
}

@JavascriptInterface
public void reload() {
EditorWebView.this.reload();
}
}

}

0 comments on commit 70b1597

Please sign in to comment.