• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 
17 package com.android.wm.shell.recents;
18 
19 import android.annotation.IntDef;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /** The listener for the events from {@link RecentsTransitionHandler}. */
25 public interface RecentsTransitionStateListener {
26 
27     @IntDef(prefix = { "TRANSITION_STATE_" }, value = {
28             TRANSITION_STATE_NOT_RUNNING,
29             TRANSITION_STATE_REQUESTED,
30             TRANSITION_STATE_ANIMATING,
31     })
32     @Retention(RetentionPolicy.SOURCE)
33     @interface RecentsTransitionState {}
34 
35     int TRANSITION_STATE_NOT_RUNNING = 1;
36     int TRANSITION_STATE_REQUESTED = 2;
37     int TRANSITION_STATE_ANIMATING = 3;
38 
39     /** Notifies whether the recents transition state changes. */
onTransitionStateChanged(@ecentsTransitionState int state)40     default void onTransitionStateChanged(@RecentsTransitionState int state) {
41     }
42 
43     /** Returns whether the recents transition is running. */
isRunning(@ecentsTransitionState int state)44     static boolean isRunning(@RecentsTransitionState int state) {
45         return state >= TRANSITION_STATE_REQUESTED;
46     }
47 
48     /** Returns whether the recents transition is animating. */
isAnimating(@ecentsTransitionState int state)49     static boolean isAnimating(@RecentsTransitionState int state) {
50         return state >= TRANSITION_STATE_ANIMATING;
51     }
52 
53     /** Returns a string representation of the given state. */
stateToString(@ecentsTransitionState int state)54     static String stateToString(@RecentsTransitionState int state) {
55         return switch (state) {
56             case TRANSITION_STATE_NOT_RUNNING -> "TRANSITION_STATE_NOT_RUNNING";
57             case TRANSITION_STATE_REQUESTED -> "TRANSITION_STATE_REQUESTED";
58             case TRANSITION_STATE_ANIMATING -> "TRANSITION_STATE_ANIMATING";
59             default -> "UNKNOWN";
60         };
61     }
62 }
63