diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-11-27 10:39:40 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-11-27 10:39:40 +0100 |
commit | e5ccea050de5d4d97953488d333bf2aae7edfc3a (patch) | |
tree | e3c3d6a24160e9ed9a9efd744da5968d78f9f1fc | |
parent | android: Change the handle type (long too ByteBuffer) (diff) | |
download | core-e5ccea050de5d4d97953488d333bf2aae7edfc3a.tar.gz core-e5ccea050de5d4d97953488d333bf2aae7edfc3a.zip |
android: reset document dimensions when changing document part
Change-Id: I2f7967ee20ad71b58e2b0dc7f182769499910373
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index 3455b7c8d8a8..0d404414c546 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -80,6 +80,7 @@ public class LOKitTileProvider implements TileProvider { Log.i(LOGTAG, "Document part " + i + " name:'" + partName + "'"); mDocument.setPart(i); + resetDocumentSize(); final DocumentPartView partView = new DocumentPartView(i, partName, thumbnail(128)); LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView); } @@ -127,20 +128,28 @@ public class LOKitTileProvider implements TileProvider { return false; } - mWidthTwip = mDocument.getDocumentWidth(); - mHeightTwip = mDocument.getDocumentHeight(); - - if (mWidthTwip == 0 || mHeightTwip == 0) { - Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError()); + boolean result = resetDocumentSize(); + if (!result) { LOKitShell.getMainHandler().post(new Runnable() { @Override public void run() { - LibreOfficeMainActivity.mAppContext.showAlertDialog("Document has no size!"); + LibreOfficeMainActivity.mAppContext.showAlertDialog("Document returned an invalid size or the document is empty!"); } }); + } + + return result; + } + + private boolean resetDocumentSize() { + mWidthTwip = mDocument.getDocumentWidth(); + mHeightTwip = mDocument.getDocumentHeight(); + + if (mWidthTwip == 0 || mHeightTwip == 0) { + Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError()); return false; } else { - Log.i(LOGTAG, "Document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight()); + Log.i(LOGTAG, "Reset document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight()); } return true; @@ -235,5 +244,6 @@ public class LOKitTileProvider implements TileProvider { @Override public void changePart(int partIndex) { mDocument.setPart(partIndex); + resetDocumentSize(); } } |