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 4, 2024
1 parent 77701eb commit d91ed25
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 @@ -113,6 +114,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 @@ -295,6 +313,11 @@ public void share() {
public void loaded() {
runOnUiThread(EditorWebView.this::hideLoading);
}

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

}

0 comments on commit d91ed25

Please sign in to comment.