Skip to content

Commit a5d7fd3

Browse files
committed
Renamed XML attributes of CardStackView
1 parent dac5fc3 commit a5d7fd3

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

cardstackview/src/main/java/com/yuyakaido/android/cardstackview/CardStackView.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public CardStackView(Context context, AttributeSet attrs, int defStyle) {
9292
setVisibleCount(array.getInt(R.styleable.CardStackView_visibleCount, option.visibleCount));
9393
setSwipeThreshold(array.getFloat(R.styleable.CardStackView_swipeThreshold, option.swipeThreshold));
9494
setStackFrom(StackFrom.values()[array.getInt(R.styleable.CardStackView_stackFrom, option.stackFrom.ordinal())]);
95-
setElevationEnabled(array.getBoolean(R.styleable.CardStackView_isElevationEnabled, option.isElevationEnabled));
96-
setSwipeEnabled(array.getBoolean(R.styleable.CardStackView_isSwipeEnabled, option.isSwipeEnabled));
97-
setEnableSwipeDirections(SwipeDirection.from(array.getInt(R.styleable.CardStackView_enableSwipeDirections, 0)));
95+
setElevationEnabled(array.getBoolean(R.styleable.CardStackView_elevationEnabled, option.isElevationEnabled));
96+
setSwipeEnabled(array.getBoolean(R.styleable.CardStackView_swipeEnabled, option.isSwipeEnabled));
97+
setSwipeDirection(SwipeDirection.from(array.getInt(R.styleable.CardStackView_swipeDirection, 0)));
9898
setLeftOverlay(array.getResourceId(R.styleable.CardStackView_leftOverlay, 0));
9999
setRightOverlay(array.getResourceId(R.styleable.CardStackView_rightOverlay, 0));
100100
array.recycle();
@@ -279,7 +279,7 @@ private void moveToTop(CardContainerView container, View child) {
279279
}
280280
}
281281

282-
private void reorderForDiscard() {
282+
private void reorderForSwipe() {
283283
moveToBottom(getTopView());
284284
containers.addLast(containers.removeFirst());
285285
}
@@ -298,7 +298,7 @@ private void executePreSwipeTask() {
298298
}
299299

300300
private void executePostSwipeTask(Point point) {
301-
reorderForDiscard();
301+
reorderForSwipe();
302302

303303
state.lastPoint = point;
304304

@@ -370,22 +370,22 @@ public void setStackFrom(StackFrom stackFrom) {
370370
}
371371
}
372372

373-
public void setElevationEnabled(boolean elevationEnabled) {
374-
option.isElevationEnabled = elevationEnabled;
373+
public void setElevationEnabled(boolean isElevationEnabled) {
374+
option.isElevationEnabled = isElevationEnabled;
375375
if (adapter != null) {
376376
initialize(false);
377377
}
378378
}
379379

380-
public void setSwipeEnabled(boolean swipeEnabled) {
381-
option.isSwipeEnabled = swipeEnabled;
380+
public void setSwipeEnabled(boolean isSwipeEnabled) {
381+
option.isSwipeEnabled = isSwipeEnabled;
382382
if (adapter != null) {
383383
initialize(false);
384384
}
385385
}
386386

387-
public void setEnableSwipeDirections(List<SwipeDirection> enableSwipeDirections) {
388-
option.enableSwipeDirections = enableSwipeDirections;
387+
public void setSwipeDirection(List<SwipeDirection> swipeDirection) {
388+
option.swipeDirection = swipeDirection;
389389
if (adapter != null) {
390390
initialize(false);
391391
}

cardstackview/src/main/java/com/yuyakaido/android/cardstackview/internal/CardContainerView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void handleActionUp(MotionEvent event) {
162162
}
163163

164164
if (Math.abs(percent) > option.swipeThreshold) {
165-
if (option.enableSwipeDirections.contains(direction)) {
165+
if (option.swipeDirection.contains(direction)) {
166166
if (containerEventListener != null) {
167167
containerEventListener.onContainerSwiped(point);
168168
}

cardstackview/src/main/java/com/yuyakaido/android/cardstackview/internal/CardStackOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ public class CardStackOption {
1313
public boolean isSwipeEnabled = true;
1414
public int leftOverlay = 0;
1515
public int rightOverlay = 0;
16-
public List<SwipeDirection> enableSwipeDirections = SwipeDirection.FREEDOM;
16+
public List<SwipeDirection> swipeDirection = SwipeDirection.FREEDOM;
1717
}

cardstackview/src/main/res/values/attrs.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<enum name="bottom" value="0"/>
99
<enum name="top" value="1"/>
1010
</attr>
11-
<attr name="isElevationEnabled" format="boolean"/>
12-
<attr name="isSwipeEnabled" format="boolean"/>
13-
<attr name="enableSwipeDirections" format="enum">
11+
<attr name="elevationEnabled" format="boolean"/>
12+
<attr name="swipeEnabled" format="boolean"/>
13+
<attr name="swipeDirection" format="enum">
1414
<enum name="freedom" value="0"/>
1515
<enum name="horizontal" value="1"/>
1616
<enum name="vertical" value="2"/>

sample/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
android:layout_height="match_parent"
88
android:clipChildren="false">
99

10-
<LinearLayout
11-
android:layout_width="match_parent"
12-
android:layout_height="match_parent"
13-
android:gravity="bottom|top">
14-
</LinearLayout>
15-
1610
<com.yuyakaido.android.cardstackview.CardStackView
1711
android:id="@+id/activity_main_card_stack_view"
1812
android:layout_width="match_parent"
@@ -23,9 +17,9 @@
2317
app:visibleCount="3"
2418
app:swipeThreshold="0.75"
2519
app:stackFrom="top"
26-
app:isElevationEnabled="true"
27-
app:isSwipeEnabled="true"
28-
app:enableSwipeDirections="horizontal"
20+
app:elevationEnabled="true"
21+
app:swipeEnabled="true"
22+
app:swipeDirection="horizontal"
2923
app:leftOverlay="@layout/view_overlay_left"
3024
app:rightOverlay="@layout/view_overlay_right"/>
3125

0 commit comments

Comments
 (0)