[Libreoffice-commits] core.git: android/source

Christian Lohmaier lohmaier+LibreOffice at googlemail.com
Thu Jan 18 10:11:07 UTC 2018


 android/source/src/java/org/libreoffice/FontController.java              |    1 
 android/source/src/java/org/libreoffice/LOKitThread.java                 |   14 +++++++---
 android/source/src/java/org/libreoffice/overlay/DocumentOverlayView.java |    2 +
 android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java |    8 ++++-
 4 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit cd581e18d6e334cc393c7bb497e07871bb962cde
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Date:   Mon Dec 18 22:23:40 2017 +0100

    tdf#112140 fix some NPEs re touch/zoom while doucment is not ready
    
    touching the screen or trying to zoom were trying to get/adjust zoom
    factor despite not ready yet, similarily swiping from the left to show
    the parts view would crash as well in case the document is not ready
    yet.
    Most likely to see this with a debug build (where loading is slower
    to begin with), or with long documents like the license text.
    
    Change-Id: Iea5e8c07a9b0973ce50f90114eb015e8e896e390
    Reviewed-on: https://gerrit.libreoffice.org/46848
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/android/source/src/java/org/libreoffice/FontController.java b/android/source/src/java/org/libreoffice/FontController.java
index 6d0ebee21ba0..db87302cbd4a 100644
--- a/android/source/src/java/org/libreoffice/FontController.java
+++ b/android/source/src/java/org/libreoffice/FontController.java
@@ -51,6 +51,7 @@ public class FontController implements AdapterView.OnItemSelectedListener {
 
         @Override
         public void updateColorPickerPosition(int color) {
+            if (null == colorPickerAdapter) return;
             colorPickerAdapter.findSelectedTextColor(color);
             changeFontColorBoxColor(color);
         }
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 99b53397b9d0..c4146fcb6b29 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -166,6 +166,10 @@ class LOKitThread extends Thread {
      * Result is stored in DocumentOverlayView class.
      */
     private void updatePartPageRectangles() {
+        if (mTileProvider == null) {
+            Log.d(LOGTAG, "mTileProvider==null when calling updatePartPageRectangles");
+            return;
+        }
         String partPageRectString = ((LOKitTileProvider) mTileProvider).getPartPageRectangles();
         List<RectF> partPageRectangles = mInvalidationHandler.convertPayloadToRectangles(partPageRectString);
         mContext.getDocumentOverlay().setPartPageRectangles(partPageRectangles);
@@ -334,16 +338,19 @@ class LOKitThread extends Thread {
                 changeHandlePosition(event.mHandleType, event.mDocumentCoordinate);
                 break;
             case LOEvent.SWIPE_LEFT:
-                onSwipeLeft();
+                if (null != mTileProvider) onSwipeLeft();
                 break;
             case LOEvent.SWIPE_RIGHT:
-                onSwipeRight();
+                if (null != mTileProvider) onSwipeRight();
                 break;
             case LOEvent.NAVIGATION_CLICK:
                 mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE);
                 break;
             case LOEvent.UNO_COMMAND:
-                mTileProvider.postUnoCommand(event.mString, event.mValue);
+                if (null == mTileProvider)
+                    Log.e(LOGTAG, "no mTileProvider when trying to process "+event.mValue+" from UNO_COMMAND "+event.mString);
+                else
+                    mTileProvider.postUnoCommand(event.mString, event.mValue);
                 break;
             case LOEvent.UPDATE_PART_PAGE_RECT:
                 updatePartPageRectangles();
@@ -361,6 +368,7 @@ class LOKitThread extends Thread {
     }
 
     private void updateCalcHeaders() {
+        if (null == mTileProvider) return;
         LOKitTileProvider tileProvider = (LOKitTileProvider)mTileProvider;
         String values = tileProvider.getCalcHeaders();
         mContext.getCalcHeadersController().setHeaders(values);
diff --git a/android/source/src/java/org/libreoffice/overlay/DocumentOverlayView.java b/android/source/src/java/org/libreoffice/overlay/DocumentOverlayView.java
index aed4432f0ad8..00dabc8a8c43 100644
--- a/android/source/src/java/org/libreoffice/overlay/DocumentOverlayView.java
+++ b/android/source/src/java/org/libreoffice/overlay/DocumentOverlayView.java
@@ -284,6 +284,7 @@ public class DocumentOverlayView extends View implements View.OnTouchListener {
      * unless there is a change of page number.
      */
     public void showPageNumberRect() {
+        if (null == mPartPageRectangles) return;
         PointF midPoint = mLayerView.getLayerClient().convertViewPointToLayerPoint(new PointF(getWidth()/2f, getHeight()/2f));
         int index = previousIndex;
         // search which page the user in currently on. can enhance the search algorithm to binary search if necessary
@@ -311,6 +312,7 @@ public class DocumentOverlayView extends View implements View.OnTouchListener {
      * Hide page number rectangle canvas element.
      */
     public void hidePageNumberRect() {
+        if (null == mPageNumberRect) return;
         if (mPageNumberRect.isVisible()) {
             mPageNumberRect.setVisible(false);
             invalidate();
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
index cf5cd25647a1..60ee318fa625 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -741,7 +741,11 @@ class JavaPanZoomController
         float maxZoomFactor = MAX_ZOOM;
 
         ZoomConstraints constraints = mTarget.getZoomConstraints();
+        if (null == constraints) {
+            Log.e(LOGTAG, "zoomConstraits not available - too impatient?");
+            return viewportMetrics;
 
+        }
         if (constraints.getMinZoom() > 0)
             minZoomFactor = constraints.getMinZoom();
         if (constraints.getMaxZoom() > 0)
@@ -824,7 +828,7 @@ class JavaPanZoomController
         if (mState == PanZoomState.ANIMATED_ZOOM)
             return false;
 
-        if (!mTarget.getZoomConstraints().getAllowZoom())
+        if (null == mTarget.getZoomConstraints() || !mTarget.getZoomConstraints().getAllowZoom())
             return false;
 
         setState(PanZoomState.PINCHING);
@@ -987,7 +991,7 @@ class JavaPanZoomController
 
     @Override
     public boolean onDoubleTap(MotionEvent motionEvent) {
-        if (!mTarget.getZoomConstraints().getAllowDoubleTapZoom()) {
+        if (null == mTarget.getZoomConstraints() || !mTarget.getZoomConstraints().getAllowDoubleTapZoom()) {
             return true;
         }
         // Double tap zooms in or out depending on the current zoom factor


More information about the Libreoffice-commits mailing list