1 /*
2  * Copyright (C) 2015 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 package android.transition.cts;
17 
18 import android.transition.Transition;
19 import android.transition.Transition.TransitionListener;
20 
21 import java.util.concurrent.CountDownLatch;
22 
23 /**
24  * Listener captures whether each of the methods is called.
25  */
26 class SimpleTransitionListener implements TransitionListener {
27     public Transition transition;
28 
29     public CountDownLatch startLatch = new CountDownLatch(1);
30     public CountDownLatch endLatch = new CountDownLatch(1);
31     public CountDownLatch cancelLatch = new CountDownLatch(1);
32     public CountDownLatch pauseLatch = new CountDownLatch(1);
33     public CountDownLatch resumeLatch = new CountDownLatch(1);
34 
35     @Override
onTransitionStart(Transition transition)36     public void onTransitionStart(Transition transition) {
37         this.transition = transition;
38         startLatch.countDown();
39     }
40 
41     @Override
onTransitionEnd(Transition transition)42     public void onTransitionEnd(Transition transition) {
43         endLatch.countDown();
44     }
45 
46     @Override
onTransitionCancel(Transition transition)47     public void onTransitionCancel(Transition transition) {
48         cancelLatch.countDown();
49     }
50 
51     @Override
onTransitionPause(Transition transition)52     public void onTransitionPause(Transition transition) {
53         pauseLatch.countDown();
54     }
55 
56     @Override
onTransitionResume(Transition transition)57     public void onTransitionResume(Transition transition) {
58         resumeLatch.countDown();
59     }
60 }
61