21
21
- [ Automatic Swipe] ( #automatic-swipe )
22
22
- [ Cancel] ( #cancel )
23
23
- [ Rewind] ( #rewind )
24
- - [ Overlay] ( #overlay )
24
+ - [ Overlay View] ( #overlay-view )
25
+ - [ Overlay Interpolator] ( #overlay-interpolator )
25
26
- [ Paging] ( #paging )
26
27
- [ Reloading] ( #reloading )
27
28
- [ Stack From] ( #stack-from )
41
42
42
43
# Setup
43
44
44
- ``` java
45
- CardStackLayoutManager manager = new CardStackLayoutManager ();
46
- CardStackAdapter adapter = new CardStackAdapter ();
47
- CardStackView cardStackView = findViewById(R . id. card_stack_view);
48
- cardStackView. setLayoutManager(manager);
49
- cardStackView. setAdapter(adapter);
45
+ ``` kotlin
46
+ val cardStackView = findViewById<CardStackView >(R .id.card_stack_view)
47
+ cardStackView.layoutManager = CardStackLayoutManager ()
48
+ cardStackView.adapter = CardStackAdapter ()
50
49
```
51
50
52
51
# Features
@@ -59,20 +58,20 @@ cardStackView.setAdapter(adapter);
59
58
60
59
![ AutomaticSwipe] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-automatic-swipe.gif )
61
60
62
- ``` java
63
- CardStackView . swipe();
61
+ ``` kotlin
62
+ CardStackView .swipe()
64
63
```
65
64
66
65
You can set custom swipe animation.
67
66
68
- ```
69
- SwipeAnimationSetting setting = new SwipeAnimationSetting.Builder()
70
- .setDirection(Direction.Right)
71
- .setDuration(200 )
72
- .setInterpolator(new AccelerateInterpolator())
73
- .build();
74
- CardStackLayoutManager.setSwipeAnimationSetting(setting);
75
- CardStackView.swipe();
67
+ ``` kotlin
68
+ val setting = SwipeAnimationSetting .Builder ()
69
+ .setDirection(Direction .Right )
70
+ .setDuration(Duration . Normal .duration )
71
+ .setInterpolator(AccelerateInterpolator ())
72
+ .build()
73
+ CardStackLayoutManager .setSwipeAnimationSetting(setting)
74
+ CardStackView .swipe()
76
75
```
77
76
78
77
## Cancel
@@ -85,23 +84,23 @@ Manual swipe is canceled when the card is dragged less than threshold.
85
84
86
85
![ Rewind] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-rewind.gif )
87
86
88
- ``` java
89
- CardStackView . rewind();
87
+ ``` kotlin
88
+ CardStackView .rewind()
90
89
```
91
90
92
91
You can set custom rewind animation.
93
92
94
- ``` java
95
- RewindAnimationSetting setting = new RewindAnimationSetting .Builder ()
96
- .setDirection(Direction . Bottom )
97
- .setDuration(200 )
98
- .setInterpolator(new DecelerateInterpolator ())
99
- .build();
100
- CardStackLayoutManager . setRewindAnimationSetting(setting);
101
- CardStackView . rewind();
93
+ ``` kotlin
94
+ val setting = RewindAnimationSetting .Builder ()
95
+ .setDirection(Direction .Bottom )
96
+ .setDuration(Duration . Normal .duration )
97
+ .setInterpolator(DecelerateInterpolator ())
98
+ .build()
99
+ CardStackLayoutManager .setRewindAnimationSetting(setting)
100
+ CardStackView .rewind()
102
101
```
103
102
104
- ## Overlay
103
+ ## Overlay View
105
104
106
105
| Value | Sample |
107
106
| :----: | :----: |
@@ -128,6 +127,14 @@ Put overlay view in your item layout of RecyclerView.
128
127
| Top | top_overlay |
129
128
| Bottom | bottom_overlay |
130
129
130
+ ## Overlay Interpolator
131
+
132
+ You can set own interpolator to define the rate of change of alpha.
133
+
134
+ ``` kotlin
135
+ CardStackLayoutManager .setOverlayInterpolator(LinearInterpolator ())
136
+ ```
137
+
131
138
## Paging
132
139
133
140
You can implement paging by using following two ways.
@@ -137,7 +144,7 @@ You can implement paging by using following two ways.
137
144
138
145
** Caution**
139
146
140
- You should ** not ** call ` RecyclerView.Adapter.notifyDataSetChanged ` for paging because this method will reset top position and maybe occur a perfomance issue.
147
+ You should ** NOT ** call ` RecyclerView.Adapter.notifyDataSetChanged ` for paging because this method will reset top position and maybe occur a perfomance issue.
141
148
142
149
## Reloading
143
150
@@ -153,8 +160,8 @@ You can implement reloading by calling `RecyclerView.Adapter.notifyDataSetChange
153
160
| | Left | ![ StackFrom-Left] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-stack-from-left.png ) |
154
161
| | Right | ![ StackFrom-Right] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-stack-from-right.png ) |
155
162
156
- ``` java
157
- CardStackLayoutManager . setStackFrom(StackFrom . None );
163
+ ``` kotlin
164
+ CardStackLayoutManager .setStackFrom(StackFrom .None )
158
165
```
159
166
160
167
## Visible Count
@@ -165,8 +172,8 @@ CardStackLayoutManager.setStackFrom(StackFrom.None);
165
172
| ✅ | 3 | ![ VisibleCount-3] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-visible-count-3.png ) |
166
173
| | 4 | ![ VisibleCount-4] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-visible-count-4.png ) |
167
174
168
- ``` java
169
- CardStackLayoutManager . setVisibleCount(3 );
175
+ ``` kotlin
176
+ CardStackLayoutManager .setVisibleCount(3 )
170
177
```
171
178
172
179
## Translation Interval
@@ -177,8 +184,8 @@ CardStackLayoutManager.setVisibleCount(3);
177
184
| ✅ | 8dp | ![ TranslationInterval-8dp] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-translation-interval-8dp.png ) |
178
185
| | 12dp | ![ TranslationInterval-12dp] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-translation-interval-12dp.png ) |
179
186
180
- ``` java
181
- CardStackLayoutManager . setTranslationInterval(8f );
187
+ ``` kotlin
188
+ CardStackLayoutManager .setTranslationInterval(8.0f )
182
189
```
183
190
184
191
## Scale Interval
@@ -188,8 +195,8 @@ CardStackLayoutManager.setTranslationInterval(8f);
188
195
| ✅ | 95% | ![ ScaleInterval-95%] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-scale-interval-95.png ) |
189
196
| | 90% | ![ ScaleInterval-90%] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-scale-interval-90.png ) |
190
197
191
- ``` java
192
- CardStackLayoutManager . setScaleInterval(0.95f );
198
+ ``` kotlin
199
+ CardStackLayoutManager .setScaleInterval(0.95f )
193
200
```
194
201
195
202
## Max Degree
@@ -199,8 +206,8 @@ CardStackLayoutManager.setScaleInterval(0.95f);
199
206
| ✅ | 20° | ![ MaxDegree-20] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-max-degree-20.png ) |
200
207
| | 0° | ![ MaxDegree-0] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-max-degree-0.png ) |
201
208
202
- ``` java
203
- CardStackLayoutManager . setMaxDegree(20f );
209
+ ``` kotlin
210
+ CardStackLayoutManager .setMaxDegree(20.0f )
204
211
```
205
212
206
213
## Swipe Direction
@@ -211,8 +218,8 @@ CardStackLayoutManager.setMaxDegree(20f);
211
218
| | Vertical | ![ SwipeDirection-Vertical] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-direction-vertical.gif ) |
212
219
| | Freedom | ![ SwipeDirection-Freedom] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-direction-freedom.gif ) |
213
220
214
- ``` java
215
- CardStackLayoutManager . setDirections(Direction . HORIZONTAL );
221
+ ``` kotlin
222
+ CardStackLayoutManager .setDirections(Direction .HORIZONTAL )
216
223
```
217
224
218
225
## Swipe Threshold
@@ -222,8 +229,8 @@ CardStackLayoutManager.setDirections(Direction.HORIZONTAL);
222
229
| ✅ | 30% | ![ SwipeThreshold-30%] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-threshold-30.gif ) |
223
230
| | 10% | ![ SwipeThreshold-10%] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-threshold-10.gif ) |
224
231
225
- ``` java
226
- CardStackLayoutManager . setSwipeThreshold(0.3f );
232
+ ``` kotlin
233
+ CardStackLayoutManager .setSwipeThreshold(0.3f )
227
234
```
228
235
229
236
## Swipe Restriction
@@ -235,9 +242,9 @@ CardStackLayoutManager.setSwipeThreshold(0.3f);
235
242
| false | true | ![ SwipeRestriction-CanScrollVerticalOnly] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-restriction-can-scroll-vertical-only.gif ) |
236
243
| false | false | ![ SwipeRestriction-CannotSwipe] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipe-restriction-cannot-swipe.gif ) |
237
244
238
- ``` java
239
- CardStackLayoutManager . setCanScrollHorizontal(true );
240
- CardStackLayoutManager . setCanScrollVertical(true );
245
+ ``` kotlin
246
+ CardStackLayoutManager .setCanScrollHorizontal(true )
247
+ CardStackLayoutManager .setCanScrollVertical(true )
241
248
```
242
249
243
250
## Swipeable Method
@@ -249,8 +256,8 @@ CardStackLayoutManager.setCanScrollVertical(true);
249
256
| | Manual | ![ SwipwableMethod-Manual] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipeable-method-manual.gif ) |
250
257
| | None | ![ SwipwableMethod-None] ( https://github.com/yuyakaido/images/blob/master/CardStackView/sample-swipeable-method-none.gif ) |
251
258
252
- ``` java
253
- CardStackLayoutManager . setSwipeableMethod(SwipeableMethod . AutomaticAndManual );
259
+ ``` kotlin
260
+ CardStackLayoutManager .setSwipeableMethod(SwipeableMethod .AutomaticAndManual )
254
261
```
255
262
256
263
# Public Interfaces
0 commit comments