AnimationFilter.java revision bf370992508c55d1f2493923bdc1834a0710e4ba
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.statusbar.stack;
18
19import java.util.ArrayList;
20
21/**
22 * Filters the animations for only a certain type of properties.
23 */
24public class AnimationFilter {
25    boolean animateAlpha;
26    boolean animateY;
27    boolean animateZ;
28    boolean animateScale;
29    boolean animateHeight;
30    boolean animateTopInset;
31    boolean animateDimmed;
32    boolean animateDark;
33    boolean hasDelays;
34
35    public AnimationFilter animateAlpha() {
36        animateAlpha = true;
37        return this;
38    }
39
40    public AnimationFilter animateY() {
41        animateY = true;
42        return this;
43    }
44
45    public AnimationFilter hasDelays() {
46        hasDelays = true;
47        return this;
48    }
49
50    public AnimationFilter animateZ() {
51        animateZ = true;
52        return this;
53    }
54
55    public AnimationFilter animateScale() {
56        animateScale = true;
57        return this;
58    }
59
60    public AnimationFilter animateHeight() {
61        animateHeight = true;
62        return this;
63    }
64
65    public AnimationFilter animateTopInset() {
66        animateTopInset = true;
67        return this;
68    }
69
70    public AnimationFilter animateDimmed() {
71        animateDimmed = true;
72        return this;
73    }
74
75    public AnimationFilter animateDark() {
76        animateDark = true;
77        return this;
78    }
79
80    /**
81     * Combines multiple filters into {@code this} filter, using or as the operand .
82     *
83     * @param events The animation events from the filters to combine.
84     */
85    public void applyCombination(ArrayList<NotificationStackScrollLayout.AnimationEvent> events) {
86        reset();
87        int size = events.size();
88        for (int i = 0; i < size; i++) {
89            combineFilter(events.get(i).filter);
90        }
91    }
92
93    private void combineFilter(AnimationFilter filter) {
94        animateAlpha |= filter.animateAlpha;
95        animateY |= filter.animateY;
96        animateZ |= filter.animateZ;
97        animateScale |= filter.animateScale;
98        animateHeight |= filter.animateHeight;
99        animateTopInset |= filter.animateTopInset;
100        animateDimmed |= filter.animateDimmed;
101        animateDark |= filter.animateDark;
102        hasDelays |= filter.hasDelays;
103    }
104
105    private void reset() {
106        animateAlpha = false;
107        animateY = false;
108        animateZ = false;
109        animateScale = false;
110        animateHeight = false;
111        animateTopInset = false;
112        animateDimmed = false;
113        animateDark = false;
114        hasDelays = false;
115    }
116}
117