Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | */ |
Chet Haase | 6ebe3de | 2013-06-17 16:50:50 -0700 | [diff] [blame] | 16 | |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 17 | package android.view.transition; |
| 18 | |
Chet Haase | 0873518 | 2013-06-04 10:44:40 -0700 | [diff] [blame] | 19 | import android.util.ArrayMap; |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 20 | import android.view.View; |
| 21 | import android.view.ViewGroup; |
| 22 | |
Chet Haase | 0873518 | 2013-06-04 10:44:40 -0700 | [diff] [blame] | 23 | import java.util.Map; |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Data structure which holds cached values for the transition. |
| 27 | * The view field is the target which all of the values pertain to. |
Chet Haase | 0873518 | 2013-06-04 10:44:40 -0700 | [diff] [blame] | 28 | * The values field is a map which holds information for fields |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 29 | * according to names selected by the transitions. These names should |
| 30 | * be unique to avoid clobbering values stored by other transitions, |
| 31 | * such as the convention project:transition_name:property_name. For |
| 32 | * example, the platform might store a property "alpha" in a transition |
| 33 | * "Fader" as "android:fader:alpha". |
| 34 | * |
| 35 | * <p>These values are cached during the |
| 36 | * {@link Transition#captureValues(TransitionValues, boolean)} |
| 37 | * capture} phases of a scene change, once when the start values are captured |
| 38 | * and again when the end values are captured. These start/end values are then |
Chet Haase | 2ea7f8b | 2013-06-21 15:00:05 -0700 | [diff] [blame] | 39 | * passed into the transitions via the |
| 40 | * for {@link Transition#play(ViewGroup, TransitionValues, TransitionValues)} |
| 41 | * method.</p> |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 42 | */ |
| 43 | public class TransitionValues { |
| 44 | |
| 45 | /** |
| 46 | * The View with these values |
| 47 | */ |
| 48 | public View view; |
| 49 | |
| 50 | /** |
| 51 | * The set of values tracked by transitions for this scene |
| 52 | */ |
Chet Haase | 0873518 | 2013-06-04 10:44:40 -0700 | [diff] [blame] | 53 | public final Map<String, Object> values = new ArrayMap<String, Object>(); |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 54 | |
| 55 | @Override |
Chet Haase | c43524f | 2013-07-16 14:40:11 -0700 | [diff] [blame] | 56 | public boolean equals(Object other) { |
| 57 | if (other instanceof TransitionValues) { |
| 58 | if (view == ((TransitionValues) other).view) { |
| 59 | if (values.equals(((TransitionValues) other).values)) { |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public int hashCode() { |
| 69 | return 31*view.hashCode() + values.hashCode(); |
| 70 | } |
| 71 | |
| 72 | @Override |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 73 | public String toString() { |
| 74 | String returnValue = "TransitionValues@" + Integer.toHexString(hashCode()) + ":\n"; |
| 75 | returnValue += " view = " + view + "\n"; |
Chet Haase | 6ebe3de | 2013-06-17 16:50:50 -0700 | [diff] [blame] | 76 | returnValue += " values:"; |
| 77 | for (String s : values.keySet()) { |
| 78 | returnValue += " " + s + ": " + values.get(s) + "\n"; |
| 79 | } |
Chet Haase | faebd8f | 2012-05-18 14:17:57 -0700 | [diff] [blame] | 80 | return returnValue; |
| 81 | } |
| 82 | } |