[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - android/experimental

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Jan 15 01:42:56 PST 2015


 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java       |   17 ++++++++--
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java |    4 --
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 04a84ecf8dcc303547ef9cddd75e0b8f0b33a2fe
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 18:40:49 2015 +0900

    android: register invalidtion callback on first touch
    
    Change-Id: I3a98358934b79a2ace574714aa331fdce4a421bb

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 30af98d..ed89536 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -4,6 +4,7 @@ import android.graphics.Bitmap;
 import android.graphics.PointF;
 import android.graphics.RectF;
 import android.util.Log;
+import android.view.MotionEvent;
 
 import org.mozilla.gecko.gfx.CairoImage;
 import org.mozilla.gecko.gfx.ComposedTileLayer;
@@ -21,6 +22,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
     private TileProvider mTileProvider;
     private ImmutableViewportMetrics mViewportMetrics;
     private GeckoLayerClient mLayerClient;
+    private boolean mInvalidationCallbackRegistered = false;
 
     public LOKitThread() {
         TileProviderFactory.initialize();
@@ -97,11 +99,10 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
         boolean isReady = mTileProvider.isReady();
         if (isReady) {
             LOKitShell.showProgressSpinner();
-            mTileProvider.registerInvalidationCallback(this);
             refresh();
             LOKitShell.hideProgressSpinner();
+            mInvalidationCallbackRegistered = false;
         }
-
         return isReady;
     }
 
@@ -143,8 +144,18 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
                 break;
             case LOEvent.THUMBNAIL:
                 createThumbnail(event.mTask);
+                break;
             case LOEvent.TOUCH:
-                LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
+                touch(event.mTouchType, event.mMotionEvent);
+                break;
+        }
+    }
+
+    private void touch(String touchType, MotionEvent motionEvent) {
+        LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
+        if (!mInvalidationCallbackRegistered) {
+            mTileProvider.registerInvalidationCallback(this);
+            mInvalidationCallbackRegistered = true;
         }
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 752e0a9..9334536 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -70,8 +70,7 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
 
     public void postLoad() {
         mDocument.initializeForRendering();
-        // FIXME see gtktiledviewer, this has to be registered when we enter edit mode, not right after loading.
-        // mDocument.setMessageCallback(this);
+        mDocument.setMessageCallback(this);
 
         int parts = mDocument.getParts();
         Log.i(LOGTAG, "Document parts: " + parts);
@@ -303,7 +302,6 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
                                 twipToPixel(x + width, mDPI),
                                 twipToPixel(y + height, mDPI)
                         );
-                        Log.i(LOGTAG, "Invalidate R: " + rect +" - " + getPageWidth() + " " + getPageHeight());
                         tileInvalidationCallback.invalidate(rect);
                     }
                 }


More information about the Libreoffice-commits mailing list