diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-02-11 07:19:47 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2012-02-11 10:21:58 +0800 |
commit | 4e05190c04eab6f4700c557ae488f3d7e344d29c (patch) | |
tree | 824dcc1b3ea982629a6d9e2e3517f0c7790fdd7f /src/com/android/gallery3d/ui | |
parent | 3d2225f6b0ff7f65620feaa283415a045718ffeb (diff) | |
download | android_packages_apps_Snap-4e05190c04eab6f4700c557ae488f3d7e344d29c.tar.gz android_packages_apps_Snap-4e05190c04eab6f4700c557ae488f3d7e344d29c.tar.bz2 android_packages_apps_Snap-4e05190c04eab6f4700c557ae488f3d7e344d29c.zip |
Use FloatMath instead of Math.
Change-Id: I41661b231f6c034dbca6af26d5950eda6c5fc7da
Diffstat (limited to 'src/com/android/gallery3d/ui')
6 files changed, 21 insertions, 16 deletions
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java index 87ff5579d..0f03da844 100644 --- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java @@ -19,6 +19,7 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.graphics.Color; import android.os.Message; +import android.util.FloatMath; import com.android.gallery3d.R; import com.android.gallery3d.app.GalleryActivity; @@ -381,8 +382,8 @@ public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) Math.floor(width * scale); - height = (int) Math.floor(height * scale); + width = (int) FloatMath.floor(width * scale); + height = (int) FloatMath.floor(height * scale); // Now draw it int sourceType = SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED; diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java index b40d72c47..6947d7fb9 100644 --- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java +++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java @@ -18,6 +18,7 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.os.Message; +import android.util.FloatMath; import com.android.gallery3d.app.GalleryActivity; import com.android.gallery3d.common.BitmapUtils; @@ -329,8 +330,8 @@ public class AlbumSlidingWindow implements AlbumView.ModelListener { float scaley = mBoxHeight / (float) height; float scale = Math.min(scalex, scaley); - width = (int) Math.floor(width * scale); - height = (int) Math.floor(height * scale); + width = (int) FloatMath.floor(width * scale); + height = (int) FloatMath.floor(height * scale); // Now draw it if (pass == 0) { diff --git a/src/com/android/gallery3d/ui/CropView.java b/src/com/android/gallery3d/ui/CropView.java index 71fdaab96..227e67e11 100644 --- a/src/com/android/gallery3d/ui/CropView.java +++ b/src/com/android/gallery3d/ui/CropView.java @@ -31,6 +31,7 @@ import android.graphics.RectF; import android.media.FaceDetector; import android.os.Handler; import android.os.Message; +import android.util.FloatMath; import android.view.MotionEvent; import android.view.animation.DecelerateInterpolator; import android.widget.Toast; @@ -756,8 +757,7 @@ public class CropView extends GLView { int rotation = mImageRotation; int width = bitmap.getWidth(); int height = bitmap.getHeight(); - float scale = (float) Math.sqrt( - (double) FACE_PIXEL_COUNT / (width * height)); + float scale = FloatMath.sqrt((float) FACE_PIXEL_COUNT / (width * height)); // faceBitmap is a correctly rotated bitmap, as viewed by a user. Bitmap faceBitmap; diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index b4dac973f..734c571b4 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -29,6 +29,7 @@ import android.graphics.Color; import android.graphics.RectF; import android.os.Message; import android.os.SystemClock; +import android.util.FloatMath; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.ScaleGestureDetector; @@ -406,7 +407,7 @@ class PositionController { // force it to be in the center. // (We do for height only, not width, because the user may // want to scroll to the previous/next image.) - if (Math.floor(mImageH * mToScale) <= mViewH) { + if (FloatMath.floor(mImageH * mToScale) <= mViewH) { mToY = mImageH / 2; } @@ -582,19 +583,19 @@ class PositionController { private void calculateStableBound(float scale, float horizontalSlack) { // The number of pixels between the center of the view // and the edge when the edge is aligned. - mBoundLeft = (int) Math.ceil((mViewW - horizontalSlack) / (2 * scale)); + mBoundLeft = (int) FloatMath.ceil((mViewW - horizontalSlack) / (2 * scale)); mBoundRight = mImageW - mBoundLeft; - mBoundTop = (int) Math.ceil(mViewH / (2 * scale)); + mBoundTop = (int) FloatMath.ceil(mViewH / (2 * scale)); mBoundBottom = mImageH - mBoundTop; // If the scaled height is smaller than the view height, // force it to be in the center. - if (Math.floor(mImageH * scale) <= mViewH) { + if (FloatMath.floor(mImageH * scale) <= mViewH) { mBoundTop = mBoundBottom = mImageH / 2; } // Same for width - if (Math.floor(mImageW * scale) <= mViewW) { + if (FloatMath.floor(mImageW * scale) <= mViewW) { mBoundLeft = mBoundRight = mImageW / 2; } } diff --git a/src/com/android/gallery3d/ui/StringTexture.java b/src/com/android/gallery3d/ui/StringTexture.java index f576c0172..935cd729e 100644 --- a/src/com/android/gallery3d/ui/StringTexture.java +++ b/src/com/android/gallery3d/ui/StringTexture.java @@ -21,6 +21,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint.FontMetricsInt; import android.graphics.Typeface; +import android.util.FloatMath; import android.text.TextPaint; import android.text.TextUtils; @@ -69,7 +70,7 @@ class StringTexture extends CanvasTexture { private static StringTexture newInstance(String text, TextPaint paint) { FontMetricsInt metrics = paint.getFontMetricsInt(); - int width = (int) Math.ceil(paint.measureText(text)); + int width = (int) FloatMath.ceil(paint.measureText(text)); int height = metrics.bottom - metrics.top; // The texture size needs to be at least 1x1. if (width <= 0) width = 1; diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 980f7b208..05d09f5b8 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -19,6 +19,7 @@ package com.android.gallery3d.ui; import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.RectF; +import android.util.FloatMath; import com.android.gallery3d.app.GalleryContext; import com.android.gallery3d.common.Utils; @@ -293,10 +294,10 @@ public class TileImageView extends GLView { int height = (int) Math.ceil(Math.max( Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h))); - int left = (int) Math.floor(cX - width / (2f * scale)); - int top = (int) Math.floor(cY - height / (2f * scale)); - int right = (int) Math.ceil(left + width / scale); - int bottom = (int) Math.ceil(top + height / scale); + int left = (int) FloatMath.floor(cX - width / (2f * scale)); + int top = (int) FloatMath.floor(cY - height / (2f * scale)); + int right = (int) FloatMath.ceil(left + width / scale); + int bottom = (int) FloatMath.ceil(top + height / scale); // align the rectangle to tile boundary int size = TILE_SIZE << level; |