TaskViewTransform.java revision 7ab650cb43fc75786eadfc1c3f8eae8a358723f6
1/*
2 * Copyright (C) 2014 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
17package com.android.systemui.recents.views;
18
19import android.graphics.Rect;
20
21
22/* The transform state for a task view */
23public class TaskViewTransform {
24    public int startDelay = 0;
25    public int translationY = 0;
26    public int translationZ = 0;
27    public float scale = 1f;
28    public float alpha = 1f;
29    public float dismissAlpha = 1f;
30    public boolean visible = false;
31    public Rect rect = new Rect();
32    float t = 0f;
33
34    public TaskViewTransform() {
35        // Do nothing
36    }
37
38    public TaskViewTransform(TaskViewTransform o) {
39        startDelay = o.startDelay;
40        translationY = o.translationY;
41        translationZ = o.translationZ;
42        scale = o.scale;
43        alpha = o.alpha;
44        dismissAlpha = o.dismissAlpha;
45        visible = o.visible;
46        rect.set(o.rect);
47        t = o.t;
48    }
49
50    /** Resets the current transform */
51    public void reset() {
52        startDelay = 0;
53        translationY = 0;
54        translationZ = 0;
55        scale = 1f;
56        alpha = 1f;
57        dismissAlpha = 1f;
58        visible = false;
59        rect.setEmpty();
60        t = 0f;
61    }
62
63    /** Convenience functions to compare against current property values */
64    public boolean hasAlphaChangedFrom(float v) {
65        return (Float.compare(alpha, v) != 0);
66    }
67    public boolean hasDismissAlphaChangedFrom(float v) {
68        return (Float.compare(dismissAlpha, v) != 0);
69    }
70    public boolean hasScaleChangedFrom(float v) {
71        return (Float.compare(scale, v) != 0);
72    }
73    public boolean hasTranslationYChangedFrom(float v) {
74        return (Float.compare(translationY, v) != 0);
75    }
76    public boolean hasTranslationZChangedFrom(float v) {
77        return (Float.compare(translationZ, v) != 0);
78    }
79
80    @Override
81    public String toString() {
82        return "TaskViewTransform delay: " + startDelay + " y: " + translationY + " z: " + translationZ +
83                " scale: " + scale + " alpha: " + alpha + " visible: " + visible + " rect: " + rect +
84                " dismissAlpha: " + dismissAlpha;
85    }
86}
87