• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 com.android.systemui.unfold
17 
18 import androidx.annotation.FloatRange
19 import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener
20 import com.android.systemui.unfold.util.CallbackController
21 
22 /**
23  * Interface that allows to receive unfold transition progress updates.
24  *
25  * It can be used to update view properties based on the current animation progress.
26  *
27  * onTransitionProgress callback could be called on each frame.
28  *
29  * Use [createUnfoldSharedComponent] to create instances of this interface when dagger is not
30  * available.
31  */
32 interface UnfoldTransitionProgressProvider : CallbackController<TransitionProgressListener> {
33 
destroynull34     fun destroy()
35 
36     interface TransitionProgressListener {
37         /** Called when transition is started */
38         fun onTransitionStarted() {}
39 
40         /**
41          * Called whenever transition progress is updated, [progress] is a value of the animation
42          * where 0 is fully folded, 1 is fully unfolded
43          */
44         fun onTransitionProgress(@FloatRange(from = 0.0, to = 1.0) progress: Float) {}
45 
46         /**
47          * Called when the progress provider determined that the transition is about to finish soon.
48          *
49          * For example, in [PhysicsBasedUnfoldTransitionProgressProvider] this could happen when the
50          * animation is not tied to the hinge angle anymore and it is about to run fixed animation.
51          */
52         fun onTransitionFinishing() {}
53 
54         /** Called when transition is completely finished */
55         fun onTransitionFinished() {}
56     }
57 }
58