Bug 1106800 - Refactor out string constants in favor of existing Enums, r=margaret
authorMark Capella <markcapella@twcny.rr.com>
Tue, 30 Dec 2014 16:42:17 -0500
changeset 247552 2329a689ff1b50f88ae1110f66ad6d7fb8ed404e
parent 247551 af6aa5d204c4d7fabe810df1f54b398186687a59
child 247553 120ddf617de1a21c604b1f82474732751a91d359
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1106800
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1106800 - Refactor out string constants in favor of existing Enums, r=margaret
mobile/android/base/TextSelection.java
mobile/android/base/TextSelectionHandle.java
--- a/mobile/android/base/TextSelection.java
+++ b/mobile/android/base/TextSelection.java
@@ -105,22 +105,26 @@ class TextSelection extends Layer implem
             "TextSelection:ShowHandles",
             "TextSelection:HideHandles",
             "TextSelection:PositionHandles",
             "TextSelection:Update",
             "TextSelection:DraggingHandle");
     }
 
     private TextSelectionHandle getHandle(String name) {
-        if (name.equals("START")) {
-            return mStartHandle;
-        } else if (name.equals("MIDDLE")) {
-            return mMiddleHandle;
-        } else {
-            return mEndHandle;
+        switch (TextSelectionHandle.HandleType.valueOf(name)) {
+            case START:
+                return mStartHandle;
+            case MIDDLE:
+                return mMiddleHandle;
+            case END:
+                return mEndHandle;
+
+            default:
+                throw new IllegalArgumentException("TextSelectionHandle is invalid type.");
         }
     }
 
     @Override
     public void handleMessage(final String event, final JSONObject message) {
         if ("TextSelection:DraggingHandle".equals(event)) {
             mDraggingHandles = message.optBoolean("dragging", false);
             return;
--- a/mobile/android/base/TextSelectionHandle.java
+++ b/mobile/android/base/TextSelectionHandle.java
@@ -17,17 +17,17 @@ import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
 
 class TextSelectionHandle extends ImageView implements View.OnTouchListener {
     private static final String LOGTAG = "GeckoTextSelectionHandle";
 
-    private enum HandleType { START, MIDDLE, END }; 
+    public enum HandleType { START, MIDDLE, END };
 
     private final HandleType mHandleType;
     private final int mWidth;
     private final int mHeight;
     private final int mShadow;
 
     private float mLeft;
     private float mTop;