1d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar/* 2d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* Copyright (C) 2014 The Android Open Source Project 3d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* 4d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* Licensed under the Apache License, Version 2.0 (the "License"); 5d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* you may not use this file except in compliance with the License. 6d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* You may obtain a copy of the License at 7d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* 8d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* http://www.apache.org/licenses/LICENSE-2.0 9d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* 10d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* Unless required by applicable law or agreed to in writing, software 11d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* distributed under the License is distributed on an "AS IS" BASIS, 12d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* See the License for the specific language governing permissions and 14d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar* limitations under the License. 15d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar*/ 16d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyarpackage android.content.res; 17d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar 18d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar/** 19d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * A cache class that can provide new instances of a particular resource which may change 20d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * depending on the current {@link Resources.Theme} or {@link Configuration}. 21d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * <p> 22d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * A constant state should be able to return a bitmask of changing configurations, which 23d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * identifies the type of configuration changes that may invalidate this resource. These 24d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * configuration changes can be obtained from {@link android.util.TypedValue}. Entities such as 25d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * {@link android.animation.Animator} also provide a changing configuration method to include 26d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * their dependencies (e.g. An AnimatorSet's changing configuration is the union of the 27d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * changing configurations of each Animator in the set) 28d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * @hide 29d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar */ 30d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyarabstract public class ConstantState<T> { 31d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar 32d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar /** 33d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * Return a bit mask of configuration changes that will impact 34d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * this resource (and thus require completely reloading it). 35d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar */ 36d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar abstract public int getChangingConfigurations(); 37d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar 38d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar /** 39d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * Create a new instance without supplying resources the caller 40d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * is running in. 41d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar */ 42d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar public abstract T newInstance(); 43d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar 44d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar /** 45d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * Create a new instance from its constant state. This 46d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * must be implemented for resources that change based on the target 47d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * density of their caller (that is depending on whether it is 48d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * in compatibility mode). 49d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar */ 50d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar public T newInstance(Resources res) { 51d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar return newInstance(); 52d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar } 53d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar 54d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar /** 55d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * Create a new instance from its constant state. This must be 56d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar * implemented for resources that can have a theme applied. 57d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar */ 58d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar public T newInstance(Resources res, Resources.Theme theme) { 59d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar return newInstance(res); 60d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar } 61d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar} 62