summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-01-28 14:15:16 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-09 08:09:26 +0100
commit3d8c72ec68f0ea2af6b7d2abf0f66c96d61910b2 (patch)
treef6c6a26d2bbb761a60f040e81b990a9a6c098006 /android
parenta8f0257871286bebad3d523759e8f07cc1c83187 (diff)
android: Use callback types, extract string to rect conversion
Change LOKitTileProvider to use callback types defined in Document. Extract conversion from payload string to rect into its own method and use it in INVALIDATE_TILES and INVALIDATE_VISIBLE_CURSOR. Change-Id: Ic908fb187568d4b6fd73770448198e1e752cc2c6
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java52
1 files changed, 35 insertions, 17 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 357fa032861e..3e3412a74984 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -339,31 +339,49 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
return mDocument.getPart();
}
+ private RectF convertCallbackMessageStringToRectF(String text) {
+ if (text.equals("EMPTY")) {
+ return null;
+ }
+
+ String[] coordinates = text.split(",");
+
+ if (coordinates.length != 4) {
+ return null;
+ }
+ int width = Integer.decode(coordinates[0].trim());
+ int height = Integer.decode(coordinates[1].trim());
+ int x = Integer.decode(coordinates[2].trim());
+ int y = Integer.decode(coordinates[3].trim());
+ RectF rect = new RectF(
+ twipToPixel(x, mDPI),
+ twipToPixel(y, mDPI),
+ twipToPixel(x + width, mDPI),
+ twipToPixel(y + height, mDPI)
+ );
+ return rect;
+ }
+
/**
* Process the retrieved messages from LOK
*/
@Override
public void messageRetrieved(int signalNumber, String payload) {
switch (signalNumber) {
- case 0:
- if (!payload.equals("EMPTY")) {
- String[] coordinates = payload.split(",");
-
- if (coordinates.length == 4) {
- int width = Integer.decode(coordinates[0].trim());
- int height = Integer.decode(coordinates[1].trim());
- int x = Integer.decode(coordinates[2].trim());
- int y = Integer.decode(coordinates[3].trim());
- RectF rect = new RectF(
- twipToPixel(x, mDPI),
- twipToPixel(y, mDPI),
- twipToPixel(x + width, mDPI),
- twipToPixel(y + height, mDPI)
- );
- tileInvalidationCallback.invalidate(rect);
- }
+ case Document.CALLBACK_INVALIDATE_TILES: {
+ RectF rect = convertCallbackMessageStringToRectF(payload);
+ if (rect != null) {
+ tileInvalidationCallback.invalidate(rect);
+ }
+ break;
+ }
+ case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR: {
+ RectF rect = convertCallbackMessageStringToRectF(payload);
+ if (rect != null) {
+ //tileInvalidationCallback.invalidate(rect);
}
break;
+ }
}
}
}