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

Christian Lohmaier lohmaier+LibreOffice at googlemail.com
Wed Apr 5 19:10:53 UTC 2017


 android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java     |    4 -
 android/source/src/java/org/libreoffice/ui/FileUtilities.java            |   22 ++--------
 android/source/src/java/org/libreoffice/ui/FolderIconView.java           |    3 -
 android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java     |    4 -
 android/source/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java |    3 -
 android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java      |    4 -
 android/source/src/java/org/mozilla/gecko/gfx/LayerView.java             |   10 ----
 7 files changed, 13 insertions(+), 37 deletions(-)

New commits:
commit c78de0018962a491cf0d0bade7d1a330ccfa1434
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Date:   Wed Apr 5 21:07:58 2017 +0200

    android: simplify some if statements, remove redundant variables
    
    Change-Id: I55a866ac66ffeab5fe2ebb45d86f68558b468650

diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 66ff92121b7a..53e956a7de69 100755
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -592,7 +592,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                if(isFormattingToolbarOpen == true){
+                if(isFormattingToolbarOpen){
                     hideBottomToolbar();
                 }else{
                     showBottomToolbar();
@@ -621,7 +621,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                if(isSearchToolbarOpen==true){
+                if(isSearchToolbarOpen){
                     hideBottomToolbar();
                 }else{
                     showBottomToolbar();
diff --git a/android/source/src/java/org/libreoffice/ui/FileUtilities.java b/android/source/src/java/org/libreoffice/ui/FileUtilities.java
index aff6e0bfd7f3..c98a505dff91 100644
--- a/android/source/src/java/org/libreoffice/ui/FileUtilities.java
+++ b/android/source/src/java/org/libreoffice/ui/FileUtilities.java
@@ -121,7 +121,7 @@ public class FileUtilities {
         extensionToMimeTypeMap.put("oth", "application/vnd.oasis.opendocument.text-web");
     }
 
-    public static final String getExtension(String filename) {
+    public static String getExtension(String filename) {
         if (filename == null)
             return "";
         int nExt = filename.lastIndexOf('.');
@@ -130,7 +130,7 @@ public class FileUtilities {
         return filename.substring(nExt);
     }
 
-    private static final int lookupExtension(String filename) {
+    private static int lookupExtension(String filename) {
         String extn = getExtension(filename);
         if (!mExtnMap.containsKey(extn))
             return UNKNOWN;
@@ -161,10 +161,7 @@ public class FileUtilities {
             return false;
 
         if (byMode == ALL && byFilename.equals("")) {
-            if (filename.startsWith(".")) {//ignore hidden files
-                return false;
-            }
-            return true;
+            return !filename.startsWith("."); //ignore hidden files
         }
         // check extension
         if (byMode != ALL) {
@@ -248,19 +245,14 @@ public class FileUtilities {
             default:
                 Log.e(LOGTAG, "uncatched sortMode: " + sortMode);
         }
-        return;
     }
 
     static boolean isHidden(File file) {
-        if (file.getName().startsWith("."))
-            return true;
-        return false;
+        return file.getName().startsWith(".");
     }
 
     static boolean isThumbnail(File file) {
-        if (isHidden(file) && file.getName().endsWith(".png"))
-            return true;
-        return false;
+        return isHidden(file) && file.getName().endsWith(".png");
     }
 
     static boolean hasThumbnail(File file) {
@@ -268,9 +260,7 @@ public class FileUtilities {
         if (lookupExtension(filename) == DOC) // only do this for docs for now
         {
             // Will need another method to check if Thumb is up-to-date - or extend this one?
-            if (new File(file.getParent() , getThumbnailName(file)).isFile())
-                return true;
-            return false; // If it's a document with no thumb
+            return new File(file.getParent(), getThumbnailName(file)).isFile();
         }
         return true;
     }
diff --git a/android/source/src/java/org/libreoffice/ui/FolderIconView.java b/android/source/src/java/org/libreoffice/ui/FolderIconView.java
index 004e5e9a8190..cde6cd27af4c 100644
--- a/android/source/src/java/org/libreoffice/ui/FolderIconView.java
+++ b/android/source/src/java/org/libreoffice/ui/FolderIconView.java
@@ -197,9 +197,6 @@ public class FolderIconView extends View{
             default:
                 break;
         }
-        //test
-
-        return;
     }
 
 }
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index e902a060a69b..bdef7022186a 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -62,13 +62,11 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     }
 
     protected static RectF normalizeRect(RectF rect, float sourceFactor, float targetFactor) {
-        RectF normalizedRect = new RectF(
+        return new RectF(
                 (rect.left / sourceFactor) * targetFactor,
                 (rect.top / sourceFactor) * targetFactor,
                 (rect.right / sourceFactor) * targetFactor,
                 (rect.bottom / sourceFactor) * targetFactor);
-
-        return normalizedRect;
     }
 
     public void invalidate() {
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java b/android/source/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
index 717aaec5d0c1..d98efa2d50f8 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
@@ -574,13 +574,12 @@ final class DisplayPortCalculator {
             float scaleFactor = Math.min(reshapedSize.width / usableSize.width, reshapedSize.height / usableSize.height);
             float displayResolution = metrics.zoomFactor * Math.min(1.0f, scaleFactor);
 
-            DisplayPortMetrics dpMetrics = new DisplayPortMetrics(
+            return new DisplayPortMetrics(
                 metrics.viewportRectLeft - margins.left,
                 metrics.viewportRectTop - margins.top,
                 metrics.viewportRectRight + margins.right,
                 metrics.viewportRectBottom + margins.bottom,
                 displayResolution);
-            return dpMetrics;
         }
 
         /**
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index ad73d50f4c36..93ab1dd26d7f 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -303,11 +303,9 @@ public class GeckoLayerClient implements PanZoomTarget {
         PointF origin = viewportMetrics.getOrigin();
         float zoom = viewportMetrics.zoomFactor;
 
-        PointF layerPoint = new PointF(
+        return new PointF(
                 ((viewPoint.x + origin.x) / zoom),
                 ((viewPoint.y + origin.y) / zoom));
-
-        return layerPoint;
     }
 
     /** Implementation of PanZoomTarget */
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
index 524efbf512dc..0aa19ddf93e2 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -170,18 +170,12 @@ public class LayerView extends FrameLayout {
 
     @Override
     public boolean onHoverEvent(MotionEvent event) {
-        if (mTouchIntercepter != null && mTouchIntercepter.onTouch(this, event)) {
-            return true;
-        }
-        return false;
+        return mTouchIntercepter != null && mTouchIntercepter.onTouch(this, event);
     }
 
     @Override
     public boolean onGenericMotionEvent(MotionEvent event) {
-        if (mPanZoomController != null && mPanZoomController.onMotionEvent(event)) {
-            return true;
-        }
-        return false;
+        return mPanZoomController != null && mPanZoomController.onMotionEvent(event);
     }
 
     public GeckoLayerClient getLayerClient() { return mLayerClient; }


More information about the Libreoffice-commits mailing list