diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-11-27 10:39:40 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-12-04 23:04:28 +0100 |
commit | dbd72b9eb833a0e116a31125186b002da4b725b4 (patch) | |
tree | 0afecd847fa23ab99660508f67f780a802f81688 /android | |
parent | 240c6d906fe720e87eaec9b91908405dc0e3edcb (diff) |
android: reset document dimensions when changing document part
Change-Id: I2f7967ee20ad71b58e2b0dc7f182769499910373
Diffstat (limited to 'android')
-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(); } } |