The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 19 | import android.animation.AnimatorSet; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 20 | import android.animation.ObjectAnimator; |
| 21 | import android.animation.TimeInterpolator; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 22 | import android.graphics.Bitmap; |
| 23 | import android.graphics.Canvas; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 24 | import android.graphics.Color; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 25 | import android.graphics.ColorFilter; |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 26 | import android.graphics.ColorMatrix; |
| 27 | import android.graphics.ColorMatrixColorFilter; |
Winson Chung | 45e1d6e | 2010-11-09 17:19:49 -0800 | [diff] [blame] | 28 | import android.graphics.Paint; |
| 29 | import android.graphics.PixelFormat; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 30 | import android.graphics.PorterDuff; |
| 31 | import android.graphics.PorterDuffColorFilter; |
Winson Chung | 45e1d6e | 2010-11-09 17:19:49 -0800 | [diff] [blame] | 32 | import android.graphics.drawable.Drawable; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 33 | import android.util.SparseArray; |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 34 | import android.view.animation.DecelerateInterpolator; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 35 | |
Hyunyoung Song | 3f47144 | 2015-04-08 19:01:34 -0700 | [diff] [blame] | 36 | public class FastBitmapDrawable extends Drawable { |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 37 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 38 | /** |
| 39 | * The possible states that a FastBitmapDrawable can be in. |
| 40 | */ |
| 41 | public enum State { |
| 42 | |
| 43 | NORMAL (0f, 0f, 1f, new DecelerateInterpolator()), |
| 44 | PRESSED (0f, 100f / 255f, 1f, CLICK_FEEDBACK_INTERPOLATOR), |
Winson | c08c59d | 2015-10-28 15:30:38 -0700 | [diff] [blame^] | 45 | FAST_SCROLL_HIGHLIGHTED (0f, 0f, 1.15f, new DecelerateInterpolator()), |
| 46 | FAST_SCROLL_UNHIGHLIGHTED (0f, 0f, 1f, new DecelerateInterpolator()), |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 47 | DISABLED (1f, 0.5f, 1f, new DecelerateInterpolator()); |
| 48 | |
| 49 | public final float desaturation; |
| 50 | public final float brightness; |
| 51 | /** |
| 52 | * Used specifically by the view drawing this FastBitmapDrawable. |
| 53 | */ |
| 54 | public final float viewScale; |
| 55 | public final TimeInterpolator interpolator; |
| 56 | |
| 57 | State(float desaturation, float brightness, float viewScale, TimeInterpolator interpolator) { |
| 58 | this.desaturation = desaturation; |
| 59 | this.brightness = brightness; |
| 60 | this.viewScale = viewScale; |
| 61 | this.interpolator = interpolator; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | public static final TimeInterpolator CLICK_FEEDBACK_INTERPOLATOR = new TimeInterpolator() { |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 66 | |
| 67 | @Override |
| 68 | public float getInterpolation(float input) { |
| 69 | if (input < 0.05f) { |
| 70 | return input / 0.05f; |
| 71 | } else if (input < 0.3f){ |
| 72 | return 1; |
| 73 | } else { |
| 74 | return (1 - input) / 0.7f; |
| 75 | } |
| 76 | } |
| 77 | }; |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 78 | public static final int CLICK_FEEDBACK_DURATION = 2000; |
| 79 | public static final int FAST_SCROLL_HIGHLIGHT_DURATION = 225; |
| 80 | public static final int FAST_SCROLL_UNHIGHLIGHT_DURATION = 150; |
| 81 | public static final int FAST_SCROLL_UNHIGHLIGHT_FROM_NORMAL_DURATION = 225; |
| 82 | public static final int FAST_SCROLL_INACTIVE_DURATION = 275; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 83 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 84 | // Since we don't need 256^2 values for combinations of both the brightness and saturation, we |
| 85 | // reduce the value space to a smaller value V, which reduces the number of cached |
| 86 | // ColorMatrixColorFilters that we need to keep to V^2 |
| 87 | private static final int REDUCED_FILTER_VALUE_SPACE = 48; |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 88 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 89 | // A cache of ColorFilters for optimizing brightness and saturation animations |
| 90 | private static final SparseArray<ColorFilter> sCachedFilter = new SparseArray<>(); |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 91 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 92 | // Temporary matrices used for calculation |
| 93 | private static final ColorMatrix sTempBrightnessMatrix = new ColorMatrix(); |
| 94 | private static final ColorMatrix sTempFilterMatrix = new ColorMatrix(); |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 95 | |
| 96 | private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG); |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 97 | private final Bitmap mBitmap; |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 98 | private State mState = State.NORMAL; |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 99 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 100 | // The saturation and brightness are values that are mapped to REDUCED_FILTER_VALUE_SPACE and |
| 101 | // as a result, can be used to compose the key for the cached ColorMatrixColorFilters |
| 102 | private int mDesaturation = 0; |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 103 | private int mBrightness = 0; |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 104 | private int mAlpha = 255; |
| 105 | private int mPrevUpdateKey = Integer.MAX_VALUE; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 106 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 107 | // Animators for the fast bitmap drawable's properties |
| 108 | private AnimatorSet mPropertyAnimator; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 109 | |
Hyunyoung Song | 3f47144 | 2015-04-08 19:01:34 -0700 | [diff] [blame] | 110 | public FastBitmapDrawable(Bitmap b) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 111 | mBitmap = b; |
Winson Chung | 268f1c5 | 2013-11-18 14:04:41 -0800 | [diff] [blame] | 112 | setBounds(0, 0, b.getWidth(), b.getHeight()); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public void draw(Canvas canvas) { |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 117 | canvas.drawBitmap(mBitmap, null, getBounds(), mPaint); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | @Override |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 121 | public void setColorFilter(ColorFilter cf) { |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 122 | // No op |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | @Override |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 126 | public int getOpacity() { |
| 127 | return PixelFormat.TRANSLUCENT; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public void setAlpha(int alpha) { |
Winson Chung | 29d6fea | 2010-12-01 15:47:31 -0800 | [diff] [blame] | 132 | mAlpha = alpha; |
Winson Chung | b3347bb | 2010-08-19 14:51:28 -0700 | [diff] [blame] | 133 | mPaint.setAlpha(alpha); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 136 | @Override |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 137 | public void setFilterBitmap(boolean filterBitmap) { |
| 138 | mPaint.setFilterBitmap(filterBitmap); |
Winson Chung | 6e1c0d3 | 2013-10-25 15:24:24 -0700 | [diff] [blame] | 139 | mPaint.setAntiAlias(filterBitmap); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Winson Chung | 29d6fea | 2010-12-01 15:47:31 -0800 | [diff] [blame] | 142 | public int getAlpha() { |
| 143 | return mAlpha; |
| 144 | } |
| 145 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 146 | @Override |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 147 | public int getIntrinsicWidth() { |
Sunny Goyal | c424f22 | 2014-09-05 07:04:59 -0700 | [diff] [blame] | 148 | return mBitmap.getWidth(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | @Override |
| 152 | public int getIntrinsicHeight() { |
Sunny Goyal | c424f22 | 2014-09-05 07:04:59 -0700 | [diff] [blame] | 153 | return mBitmap.getHeight(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | @Override |
| 157 | public int getMinimumWidth() { |
Winson Chung | eeb5bbc | 2013-11-13 15:47:05 -0800 | [diff] [blame] | 158 | return getBounds().width(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public int getMinimumHeight() { |
Winson Chung | eeb5bbc | 2013-11-13 15:47:05 -0800 | [diff] [blame] | 163 | return getBounds().height(); |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 164 | } |
| 165 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 166 | public Bitmap getBitmap() { |
| 167 | return mBitmap; |
| 168 | } |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 169 | |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 170 | /** |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 171 | * Animates this drawable to a new state. |
| 172 | * |
| 173 | * @return whether the state has changed. |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 174 | */ |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 175 | public boolean animateState(State newState) { |
| 176 | State prevState = mState; |
| 177 | if (mState != newState) { |
| 178 | mState = newState; |
| 179 | |
| 180 | mPropertyAnimator = cancelAnimator(mPropertyAnimator); |
| 181 | mPropertyAnimator = new AnimatorSet(); |
| 182 | mPropertyAnimator.playTogether( |
| 183 | ObjectAnimator |
| 184 | .ofFloat(this, "desaturation", newState.desaturation), |
| 185 | ObjectAnimator |
| 186 | .ofFloat(this, "brightness", newState.brightness)); |
| 187 | mPropertyAnimator.setInterpolator(newState.interpolator); |
| 188 | mPropertyAnimator.setDuration(getDurationForStateChange(prevState, newState)); |
| 189 | mPropertyAnimator.setStartDelay(getStartDelayForStateChange(prevState, newState)); |
| 190 | mPropertyAnimator.start(); |
| 191 | return true; |
| 192 | } |
| 193 | return false; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Immediately sets this drawable to a new state. |
| 198 | * |
| 199 | * @return whether the state has changed. |
| 200 | */ |
| 201 | public boolean setState(State newState) { |
| 202 | if (mState != newState) { |
| 203 | mState = newState; |
| 204 | |
| 205 | mPropertyAnimator = cancelAnimator(mPropertyAnimator); |
| 206 | |
| 207 | setDesaturation(newState.desaturation); |
| 208 | setBrightness(newState.brightness); |
| 209 | return true; |
| 210 | } |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Returns the current state. |
| 216 | */ |
| 217 | public State getCurrentState() { |
| 218 | return mState; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Returns the duration for the state change animation. |
| 223 | */ |
| 224 | public static int getDurationForStateChange(State fromState, State toState) { |
| 225 | switch (toState) { |
| 226 | case NORMAL: |
| 227 | switch (fromState) { |
| 228 | case PRESSED: |
| 229 | return 0; |
| 230 | case FAST_SCROLL_HIGHLIGHTED: |
| 231 | case FAST_SCROLL_UNHIGHLIGHTED: |
| 232 | return FAST_SCROLL_INACTIVE_DURATION; |
| 233 | } |
| 234 | case PRESSED: |
| 235 | return CLICK_FEEDBACK_DURATION; |
| 236 | case FAST_SCROLL_HIGHLIGHTED: |
| 237 | return FAST_SCROLL_HIGHLIGHT_DURATION; |
| 238 | case FAST_SCROLL_UNHIGHLIGHTED: |
| 239 | switch (fromState) { |
| 240 | case NORMAL: |
| 241 | // When animating from normal state, take a little longer |
| 242 | return FAST_SCROLL_UNHIGHLIGHT_FROM_NORMAL_DURATION; |
| 243 | default: |
| 244 | return FAST_SCROLL_UNHIGHLIGHT_DURATION; |
| 245 | } |
| 246 | } |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Returns the start delay when animating between certain fast scroll states. |
| 252 | */ |
| 253 | public static int getStartDelayForStateChange(State fromState, State toState) { |
| 254 | switch (toState) { |
| 255 | case FAST_SCROLL_UNHIGHLIGHTED: |
| 256 | switch (fromState) { |
| 257 | case NORMAL: |
| 258 | return FAST_SCROLL_UNHIGHLIGHT_DURATION / 4; |
| 259 | } |
| 260 | } |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Sets the saturation of this icon, 0 [full color] -> 1 [desaturated] |
| 266 | */ |
| 267 | public void setDesaturation(float desaturation) { |
| 268 | int newDesaturation = (int) Math.floor(desaturation * REDUCED_FILTER_VALUE_SPACE); |
| 269 | if (mDesaturation != newDesaturation) { |
| 270 | mDesaturation = newDesaturation; |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 271 | updateFilter(); |
| 272 | } |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 275 | public float getDesaturation() { |
| 276 | return (float) mDesaturation / REDUCED_FILTER_VALUE_SPACE; |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 279 | /** |
| 280 | * Sets the brightness of this icon, 0 [no add. brightness] -> 1 [2bright2furious] |
| 281 | */ |
| 282 | public void setBrightness(float brightness) { |
| 283 | int newBrightness = (int) Math.floor(brightness * REDUCED_FILTER_VALUE_SPACE); |
| 284 | if (mBrightness != newBrightness) { |
| 285 | mBrightness = newBrightness; |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 286 | updateFilter(); |
| 287 | } |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 290 | public float getBrightness() { |
| 291 | return (float) mBrightness / REDUCED_FILTER_VALUE_SPACE; |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Updates the paint to reflect the current brightness and saturation. |
| 296 | */ |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 297 | private void updateFilter() { |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 298 | boolean usePorterDuffFilter = false; |
| 299 | int key = -1; |
| 300 | if (mDesaturation > 0) { |
| 301 | key = (mDesaturation << 16) | mBrightness; |
| 302 | } else if (mBrightness > 0) { |
| 303 | // Compose a key with a fully saturated icon if we are just animating brightness |
| 304 | key = (1 << 16) | mBrightness; |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 305 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 306 | // We found that in L, ColorFilters cause drawing artifacts with shadows baked into |
| 307 | // icons, so just use a PorterDuff filter when we aren't animating saturation |
| 308 | usePorterDuffFilter = true; |
| 309 | } |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 310 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 311 | // Debounce multiple updates on the same frame |
| 312 | if (key == mPrevUpdateKey) { |
| 313 | return; |
| 314 | } |
| 315 | mPrevUpdateKey = key; |
| 316 | |
| 317 | if (key != -1) { |
| 318 | ColorFilter filter = sCachedFilter.get(key); |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 319 | if (filter == null) { |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 320 | float brightnessF = getBrightness(); |
| 321 | int brightnessI = (int) (255 * brightnessF); |
| 322 | if (usePorterDuffFilter) { |
| 323 | filter = new PorterDuffColorFilter(Color.argb(brightnessI, 255, 255, 255), |
| 324 | PorterDuff.Mode.SRC_ATOP); |
| 325 | } else { |
| 326 | float saturationF = 1f - getDesaturation(); |
| 327 | sTempFilterMatrix.setSaturation(saturationF); |
| 328 | if (mBrightness > 0) { |
| 329 | // Brightness: C-new = C-old*(1-amount) + amount |
| 330 | float scale = 1f - brightnessF; |
| 331 | float[] mat = sTempBrightnessMatrix.getArray(); |
| 332 | mat[0] = scale; |
| 333 | mat[6] = scale; |
| 334 | mat[12] = scale; |
| 335 | mat[4] = brightnessI; |
| 336 | mat[9] = brightnessI; |
| 337 | mat[14] = brightnessI; |
| 338 | sTempFilterMatrix.preConcat(sTempBrightnessMatrix); |
| 339 | } |
| 340 | filter = new ColorMatrixColorFilter(sTempFilterMatrix); |
| 341 | } |
| 342 | sCachedFilter.append(key, filter); |
Sunny Goyal | 508da15 | 2014-08-14 10:53:27 -0700 | [diff] [blame] | 343 | } |
| 344 | mPaint.setColorFilter(filter); |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 345 | } else { |
| 346 | mPaint.setColorFilter(null); |
| 347 | } |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 348 | invalidateSelf(); |
Sunny Goyal | c5c60ad | 2014-07-14 12:02:01 -0700 | [diff] [blame] | 349 | } |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 350 | |
Winson | c088049 | 2015-08-21 11:16:27 -0700 | [diff] [blame] | 351 | private AnimatorSet cancelAnimator(AnimatorSet animator) { |
| 352 | if (animator != null) { |
| 353 | animator.removeAllListeners(); |
| 354 | animator.cancel(); |
| 355 | } |
| 356 | return null; |
Sunny Goyal | 95abbb3 | 2014-08-04 10:53:22 -0700 | [diff] [blame] | 357 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 358 | } |