OSDN Git Service

CameraUtil: add float clamp function
authorIgor Murashkin <iam@google.com>
Mon, 14 Oct 2013 21:57:30 +0000 (14:57 -0700)
committerIgor Murashkin <iam@google.com>
Mon, 14 Oct 2013 21:57:30 +0000 (14:57 -0700)
Bug: 10936156
Change-Id: I5fbaf399ed8ca0206d23aa7d0af11c9b8a1debe5

src/com/android/camera/util/CameraUtil.java

index f442f22..0653199 100644 (file)
@@ -392,6 +392,12 @@ public class CameraUtil {
         return x;
     }
 
+    public static float clamp(float x, float min, float max) {
+        if (x > max) return max;
+        if (x < min) return min;
+        return x;
+    }
+
     public static int getDisplayRotation(Activity activity) {
         int rotation = activity.getWindowManager().getDefaultDisplay()
                 .getRotation();
@@ -825,7 +831,7 @@ public class CameraUtil {
     }
 
     private static class ImageFileNamer {
-        private SimpleDateFormat mFormat;
+        private final SimpleDateFormat mFormat;
 
         // The date (in milliseconds) used to generate the last name.
         private long mLastDate;