• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.launcher3.util;
18 
19 import android.annotation.TargetApi;
20 import android.os.Build;
21 
22 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
23 public class CircleRevealOutlineProvider extends RevealOutlineAnimation {
24 
25     private int mCenterX;
26     private int mCenterY;
27     private float mRadius0;
28     private float mRadius1;
29 
30     /**
31      * @param x reveal center x
32      * @param y reveal center y
33      * @param r0 initial radius
34      * @param r1 final radius
35      */
CircleRevealOutlineProvider(int x, int y, float r0, float r1)36     public CircleRevealOutlineProvider(int x, int y, float r0, float r1) {
37         mCenterX = x;
38         mCenterY = y;
39         mRadius0 = r0;
40         mRadius1 = r1;
41     }
42 
43     @Override
shouldRemoveElevationDuringAnimation()44     public boolean shouldRemoveElevationDuringAnimation() {
45         return true;
46     }
47 
48     @Override
setProgress(float progress)49     public void setProgress(float progress) {
50         mOutlineRadius = (1 - progress) * mRadius0 + progress * mRadius1;
51 
52         mOutline.left = (int) (mCenterX - mOutlineRadius);
53         mOutline.top = (int) (mCenterY - mOutlineRadius);
54         mOutline.right = (int) (mCenterX + mOutlineRadius);
55         mOutline.bottom = (int) (mCenterY + mOutlineRadius);
56     }
57 }
58