Home | History | Annotate | Download | only in util
      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 public class CircleRevealOutlineProvider extends RevealOutlineAnimation {
     20 
     21     private int mCenterX;
     22     private int mCenterY;
     23     private float mRadius0;
     24     private float mRadius1;
     25 
     26     /**
     27      * @param x reveal center x
     28      * @param y reveal center y
     29      * @param r0 initial radius
     30      * @param r1 final radius
     31      */
     32     public CircleRevealOutlineProvider(int x, int y, float r0, float r1) {
     33         mCenterX = x;
     34         mCenterY = y;
     35         mRadius0 = r0;
     36         mRadius1 = r1;
     37     }
     38 
     39     @Override
     40     public boolean shouldRemoveElevationDuringAnimation() {
     41         return true;
     42     }
     43 
     44     @Override
     45     public void setProgress(float progress) {
     46         mOutlineRadius = (1 - progress) * mRadius0 + progress * mRadius1;
     47 
     48         mOutline.left = (int) (mCenterX - mOutlineRadius);
     49         mOutline.top = (int) (mCenterY - mOutlineRadius);
     50         mOutline.right = (int) (mCenterX + mOutlineRadius);
     51         mOutline.bottom = (int) (mCenterY + mOutlineRadius);
     52     }
     53 }
     54