-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathSheet.java
115 lines (100 loc) · 3.13 KB
/
Sheet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.material.sidesheet;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
import androidx.annotation.IntDef;
import androidx.annotation.RestrictTo;
import com.google.android.material.motion.MaterialBackHandler;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Interface for sheet constants and {@code IntDefs} to be shared between the different {@link
* Sheet} implementations.
*/
interface Sheet<C extends SheetCallback> extends MaterialBackHandler {
/** The sheet is dragging. */
int STATE_DRAGGING = 1;
/** The sheet is settling. */
int STATE_SETTLING = 2;
/** The sheet is expanded. */
int STATE_EXPANDED = 3;
/** The sheet is hidden. */
int STATE_HIDDEN = 5;
/**
* States that a sheet can be in.
*
* <p>Note: {@link Sheet} implementations are not guaranteed to support all states.
*/
@RestrictTo(LIBRARY_GROUP)
@IntDef({
STATE_EXPANDED,
STATE_DRAGGING,
STATE_SETTLING,
STATE_HIDDEN,
})
@Retention(RetentionPolicy.SOURCE)
@interface SheetState {}
/**
* Stable states that can be set by the a sheet's {@code setState(int)} method. These includes all
* the possible states a sheet can be in when it's settled.
*
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
@IntDef({STATE_EXPANDED, STATE_HIDDEN})
@Retention(RetentionPolicy.SOURCE)
@interface StableSheetState {}
/**
* The sheet is based on the right edge of the screen; it slides from the right edge towards the
* left.
*/
int EDGE_RIGHT = 0;
/**
* The sheet is based on the left edge of the screen; it slides from the left edge towards the
* right.
*/
int EDGE_LEFT = 1;
/**
* The edge of the screen that a sheet slides out of.
*
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
@IntDef({EDGE_RIGHT, EDGE_LEFT})
@Retention(RetentionPolicy.SOURCE)
@interface SheetEdge {}
/**
* Gets the current state of the sheet.
*
* @return One of {@link #STATE_EXPANDED}, {@link #STATE_DRAGGING}, or {@link #STATE_SETTLING}.
*/
@SheetState
int getState();
/** Sets the current state of the sheet. Must be one of {@link StableSheetState}. */
void setState(@StableSheetState int state);
/**
* Adds a callback to be notified of sheet events.
*
* @param callback The callback to notify when sheet events occur.
*/
void addCallback(C callback);
/**
* Removes a callback to be notified of sheet events.
*
* @param callback The callback to remove
*/
void removeCallback(C callback);
}