summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util/RevealOutlineProvider.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2015-05-26 23:03:31 -0700
committerAdam Cohen <adamcohen@google.com>2015-05-27 13:55:09 -0700
commit1558893b873cd55b2df779f594f1de3c370d3328 (patch)
treedc79aa6ae27c704d74ce904a9860c9ae320e898c /src/com/android/launcher3/util/RevealOutlineProvider.java
parentbbcf5ac7aa73a3ce07215d77a0b496cf7fb00f29 (diff)
downloadandroid_packages_apps_Trebuchet-1558893b873cd55b2df779f594f1de3c370d3328.tar.gz
android_packages_apps_Trebuchet-1558893b873cd55b2df779f594f1de3c370d3328.tar.bz2
android_packages_apps_Trebuchet-1558893b873cd55b2df779f594f1de3c370d3328.zip
Make sure all transition components run on the same thread
-> The framework circular reveal transition runs on the render thread which can cause problems when mixed in an AnimatorSet with transitions that don't run on the render thread -> See issue 17556455 issue 21445293 Change-Id: Ie19c184c55060651e817d426ec83049b06af56ba
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);
+ }
+}