summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-04-13 13:52:40 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-04-13 18:23:02 +0200
commitd2572dc9d6c7cda9d6e08e46c42048e12e4f04e0 (patch)
tree633d016dab798a9928d7e4c50e762c1a1bc8ee43 /android
parent4476fd51a324930e832535c10979564afc6968f2 (diff)
android: Deduplicate LOKitThread#load{,New}Document
After Change-Id I15ecc2eba6c5ee441f6e14f8229594cab05dbba7 "tdf#148556 android: Don't delay refresh when loading doc", the only thing that `LOKitThread#loadNewDocument` does in addition to `LOKithThread#loadDocument` is to save the newly created document (to a temp file) if loading was successful. So, have `loadDocument` return a boolean saying whether loading was successful and call that method from `loadNewDocument` to reduce duplication. Change-Id: I9b99e011b3f5105bb60f95174de393462ff08271 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132966 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java20
1 files changed, 6 insertions, 14 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index b4aee40c1cd3..c29f98461fb9 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -204,8 +204,9 @@ class LOKitThread extends Thread {
/**
* Handle load document event.
* @param filePath - filePath to where the document is located
+ * @return Whether the document has been loaded successfully.
*/
- private void loadDocument(String filePath) {
+ private boolean loadDocument(String filePath) {
mLayerClient = mContext.getLayerClient();
mInvalidationHandler = new InvalidationHandler(mContext);
@@ -216,8 +217,10 @@ class LOKitThread extends Thread {
updateZoomConstraints();
refresh(true);
LOKitShell.hideProgressSpinner(mContext);
+ return true;
} else {
closeDocument();
+ return false;
}
}
@@ -227,20 +230,9 @@ class LOKitThread extends Thread {
* @param fileType - fileType what type of new document is to be loaded
*/
private void loadNewDocument(String filePath, String fileType) {
- mLayerClient = mContext.getLayerClient();
-
- mInvalidationHandler = new InvalidationHandler(mContext);
- mTileProvider = TileProviderFactory.create(mContext, mInvalidationHandler, fileType);
-
- if (mTileProvider.isReady()) {
- LOKitShell.showProgressSpinner(mContext);
- updateZoomConstraints();
- refresh(true);
- LOKitShell.hideProgressSpinner(mContext);
-
+ boolean ok = loadDocument(fileType);
+ if (ok) {
mTileProvider.saveDocumentAs(filePath, true);
- } else {
- closeDocument();
}
}