/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.animation; import android.content.pm.ActivityInfo.Config; import android.content.res.ConstantState; import android.util.StateSet; import android.view.View; import java.lang.ref.WeakReference; import java.util.ArrayList; /** * Lets you define a number of Animators that will run on the attached View depending on the View's * drawable state. *
* It can be defined in an XML file with the
* This causes the animation to assign the end value(s) to the View.
*/
public void jumpToCurrentState() {
if (mRunningAnimator != null) {
mRunningAnimator.end();
}
}
/**
* Return a mask of the configuration parameters for which this animator may change, requiring
* that it be re-created. The default implementation returns whatever was provided through
* {@link #setChangingConfigurations(int)} or 0 by default.
*
* @return Returns a mask of the changing configuration parameters, as defined by
* {@link android.content.pm.ActivityInfo}.
*
* @see android.content.pm.ActivityInfo
* @hide
*/
public @Config int getChangingConfigurations() {
return mChangingConfigurations;
}
/**
* Set a mask of the configuration parameters for which this animator may change, requiring
* that it should be recreated from resources instead of being cloned.
*
* @param configs A mask of the changing configuration parameters, as
* defined by {@link android.content.pm.ActivityInfo}.
*
* @see android.content.pm.ActivityInfo
* @hide
*/
public void setChangingConfigurations(@Config int configs) {
mChangingConfigurations = configs;
}
/**
* Sets the changing configurations value to the union of the current changing configurations
* and the provided configs.
* This method is called while loading the animator.
* @hide
*/
public void appendChangingConfigurations(@Config int configs) {
mChangingConfigurations |= configs;
}
/**
* Return a {@link android.content.res.ConstantState} instance that holds the shared state of
* this Animator.
*
* This constant state is used to create new instances of this animator when needed. Default
* implementation creates a new {@link StateListAnimatorConstantState}. You can override this
* method to provide your custom logic or return null if you don't want this animator to be
* cached.
*
* @return The {@link android.content.res.ConstantState} associated to this Animator.
* @see android.content.res.ConstantState
* @see #clone()
* @hide
*/
public ConstantState
* When new instance is called, default implementation clones the Animator.
*/
private static class StateListAnimatorConstantState
extends ConstantState<selector>
element.
* Each State Animator is defined in a nested <item>
element.
*
* @attr ref android.R.styleable#DrawableStates_state_focused
* @attr ref android.R.styleable#DrawableStates_state_window_focused
* @attr ref android.R.styleable#DrawableStates_state_enabled
* @attr ref android.R.styleable#DrawableStates_state_checkable
* @attr ref android.R.styleable#DrawableStates_state_checked
* @attr ref android.R.styleable#DrawableStates_state_selected
* @attr ref android.R.styleable#DrawableStates_state_activated
* @attr ref android.R.styleable#DrawableStates_state_active
* @attr ref android.R.styleable#DrawableStates_state_single
* @attr ref android.R.styleable#DrawableStates_state_first
* @attr ref android.R.styleable#DrawableStates_state_middle
* @attr ref android.R.styleable#DrawableStates_state_last
* @attr ref android.R.styleable#DrawableStates_state_pressed
* @attr ref android.R.styleable#StateListAnimatorItem_animation
*/
public class StateListAnimator implements Cloneable {
private ArrayList