10cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek/* 20cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * Copyright (C) 2016 The Android Open Source Project 30cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * 40cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * Licensed under the Apache License, Version 2.0 (the "License"); 50cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * you may not use this file except in compliance with the License. 60cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * You may obtain a copy of the License at 70cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * 80cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * http://www.apache.org/licenses/LICENSE-2.0 90cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * 100cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * Unless required by applicable law or agreed to in writing, software 110cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * distributed under the License is distributed on an "AS IS" BASIS, 120cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * See the License for the specific language governing permissions and 140cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * limitations under the License 150cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek */ 160cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 170cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekpackage com.android.systemui.statusbar.stack; 180cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 190cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport android.animation.AnimatorListenerAdapter; 20061d90729bba582395e9050898dab20fd434cf66Selim Cinekimport android.util.ArrayMap; 210cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport android.util.Property; 220cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport android.view.View; 230cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekimport android.view.animation.Interpolator; 240cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 25061d90729bba582395e9050898dab20fd434cf66Selim Cinekimport java.util.HashMap; 26061d90729bba582395e9050898dab20fd434cf66Selim Cinek 270cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek/** 280cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * Properties for a View animation 290cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek */ 300cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinekpublic class AnimationProperties { 310cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public long duration; 320cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public long delay; 33061d90729bba582395e9050898dab20fd434cf66Selim Cinek private ArrayMap<Property, Interpolator> mInterpolatorMap; 340cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 350cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek /** 360cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * @return an animation filter for this animation. 370cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek */ 380cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public AnimationFilter getAnimationFilter() { 39c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek return new AnimationFilter(); 400cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 410cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 420cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek /** 430cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * @return a listener that should be run whenever any property finished its animation 440cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek */ 450cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public AnimatorListenerAdapter getAnimationFinishListener() { 460cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek return null; 470cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 480cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 490cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek public boolean wasAdded(View view) { 500cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek return false; 510cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 520cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek 530cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek /** 540cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek * Get a custom interpolator for a property instead of the normal one. 550cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek */ 56c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek public Interpolator getCustomInterpolator(View child, Property property) { 57061d90729bba582395e9050898dab20fd434cf66Selim Cinek return mInterpolatorMap != null ? mInterpolatorMap.get(property) : null; 58061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 59061d90729bba582395e9050898dab20fd434cf66Selim Cinek 60061d90729bba582395e9050898dab20fd434cf66Selim Cinek 61061d90729bba582395e9050898dab20fd434cf66Selim Cinek public void combineCustomInterpolators(AnimationProperties iconAnimationProperties) { 62061d90729bba582395e9050898dab20fd434cf66Selim Cinek ArrayMap<Property, Interpolator> map = iconAnimationProperties.mInterpolatorMap; 63061d90729bba582395e9050898dab20fd434cf66Selim Cinek if (map != null) { 64061d90729bba582395e9050898dab20fd434cf66Selim Cinek if (mInterpolatorMap == null) { 65061d90729bba582395e9050898dab20fd434cf66Selim Cinek mInterpolatorMap = new ArrayMap<>(); 66061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 67061d90729bba582395e9050898dab20fd434cf66Selim Cinek mInterpolatorMap.putAll(map); 68061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 69061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 70061d90729bba582395e9050898dab20fd434cf66Selim Cinek 71061d90729bba582395e9050898dab20fd434cf66Selim Cinek /** 72061d90729bba582395e9050898dab20fd434cf66Selim Cinek * Set a custom interpolator to use for all views for a property. 73061d90729bba582395e9050898dab20fd434cf66Selim Cinek */ 74061d90729bba582395e9050898dab20fd434cf66Selim Cinek public AnimationProperties setCustomInterpolator(Property property, Interpolator interpolator) { 75061d90729bba582395e9050898dab20fd434cf66Selim Cinek if (mInterpolatorMap == null) { 76061d90729bba582395e9050898dab20fd434cf66Selim Cinek mInterpolatorMap = new ArrayMap<>(); 77061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 78061d90729bba582395e9050898dab20fd434cf66Selim Cinek mInterpolatorMap.put(property, interpolator); 79061d90729bba582395e9050898dab20fd434cf66Selim Cinek return this; 800cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek } 81c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek 82c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek public AnimationProperties setDuration(long duration) { 83c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek this.duration = duration; 84c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek return this; 85c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek } 86c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek 87c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek public AnimationProperties setDelay(long delay) { 88c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek this.delay = delay; 89c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek return this; 90c40c79ac66d8162880e0ef76c98f44bc40797bbdSelim Cinek } 91061d90729bba582395e9050898dab20fd434cf66Selim Cinek 92061d90729bba582395e9050898dab20fd434cf66Selim Cinek public AnimationProperties resetCustomInterpolators() { 93061d90729bba582395e9050898dab20fd434cf66Selim Cinek mInterpolatorMap = null; 94061d90729bba582395e9050898dab20fd434cf66Selim Cinek return this; 95061d90729bba582395e9050898dab20fd434cf66Selim Cinek } 960cfbef45f037efe966a5f57af63a328f6fd5d989Selim Cinek} 97