summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util/RevealOutlineProvider.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-07-21 17:01:26 -0700
committerEd Heyl <edheyl@google.com>2015-07-22 11:31:04 -0700
commite612775922ec9f8cc4e5cb976bc62b3312a3de0e (patch)
tree96beaf07307486f6491f022da63ebe381765d1a8 /src/com/android/launcher3/util/RevealOutlineProvider.java
parenta83129f0bc778fd1ccd799bd8cfa40270f632e1d (diff)
downloadandroid_packages_apps_Trebuchet-e612775922ec9f8cc4e5cb976bc62b3312a3de0e.tar.gz
android_packages_apps_Trebuchet-e612775922ec9f8cc4e5cb976bc62b3312a3de0e.tar.bz2
android_packages_apps_Trebuchet-e612775922ec9f8cc4e5cb976bc62b3312a3de0e.zip
resolved conflicts for merge of 13ef17a3 to mnc-dr-dev
b/22609402 Change-Id: I140cf972d57e14737a6f91c0b4a8ec6c7ff1af2b
Diffstat (limited to 'src/com/android/launcher3/util/RevealOutlineProvider.java')
-rw-r--r--src/com/android/launcher3/util/RevealOutlineProvider.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/com/android/launcher3/util/RevealOutlineProvider.java b/src/com/android/launcher3/util/RevealOutlineProvider.java
new file mode 100644
index 000000000..0db3984f8
--- /dev/null
+++ b/src/com/android/launcher3/util/RevealOutlineProvider.java
@@ -0,0 +1,49 @@
+package com.android.launcher3.util;
+
+import android.annotation.TargetApi;
+import android.graphics.Outline;
+import android.graphics.Rect;
+import android.os.Build;
+import android.view.View;
+import android.view.ViewOutlineProvider;
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+public class RevealOutlineProvider extends ViewOutlineProvider {
+
+ private int mCenterX;
+ private int mCenterY;
+ private float mRadius0;
+ private float mRadius1;
+ private int mCurrentRadius;
+
+ private final Rect mOval;
+
+ /**
+ * @param x reveal center x
+ * @param y reveal center y
+ * @param r0 initial radius
+ * @param r1 final radius
+ */
+ public RevealOutlineProvider(int x, int y, float r0, float r1) {
+ mCenterX = x;
+ mCenterY = y;
+ mRadius0 = r0;
+ mRadius1 = r1;
+
+ mOval = new Rect();
+ }
+
+ public void setProgress(float progress) {
+ mCurrentRadius = (int) ((1 - progress) * mRadius0 + progress * mRadius1);
+
+ mOval.left = mCenterX - mCurrentRadius;
+ mOval.top = mCenterY - mCurrentRadius;
+ mOval.right = mCenterX + mCurrentRadius;
+ mOval.bottom = mCenterY + mCurrentRadius;
+ }
+
+ @Override
+ public void getOutline(View v, Outline outline) {
+ outline.setRoundRect(mOval, mCurrentRadius);
+ }
+}