Skip to content

Commit 19079c7

Browse files
committed
Merge pull request daimajia#93 from HarshEvilGeek/master
Adding support for multiple drag edges on a single view and touchSlop
2 parents cacc6e6 + a8b4b08 commit 19079c7

File tree

7 files changed

+825
-446
lines changed

7 files changed

+825
-446
lines changed

demo/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ repositories {
77
android {
88
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
99
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
10-
1110
defaultConfig {
1211
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
1312
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)

demo/src/main/java/com/daimajia/swipedemo/MyActivity.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,43 @@ protected void onCreate(Bundle savedInstanceState) {
2727
//sample1
2828

2929
sample1 = (SwipeLayout) findViewById(R.id.sample1);
30-
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
31-
sample1.setDragEdge(SwipeLayout.DragEdge.Left);
30+
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
31+
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
32+
// When using multiple drag edges it's a good idea to pass the ids of the views that you're using for the left, right, top bottom views (-1 if you're not using a particular view)
33+
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT);
3234
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
3335
@Override
3436
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
3537

3638
}
3739
});
3840

41+
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
42+
@Override
43+
public void onClick(View v) {
44+
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
45+
}
46+
});
47+
48+
sample1.findViewById(R.id.trash2).setOnClickListener(new View.OnClickListener() {
49+
@Override
50+
public void onClick(View v) {
51+
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
52+
}
53+
});
54+
55+
sample1.findViewById(R.id.magnifier2).setOnClickListener(new View.OnClickListener() {
56+
@Override
57+
public void onClick(View v) {
58+
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
59+
}
60+
});
61+
3962
//sample2
4063

4164
sample2 = (SwipeLayout) findViewById(R.id.sample2);
4265
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
66+
sample2.setDragEdge(SwipeLayout.DragEdge.Right);
4367
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
4468
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
4569
@Override

demo/src/main/res/layout/listview_item.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
android:id="@+id/swipe"
66
android:layout_width="match_parent"
77
android:layout_height="wrap_content"
8-
swipe:horizontalSwipeOffset="0dp">
8+
swipe:leftEdgeSwipeOffset="0dp"
9+
swipe:rightEdgeSwipeOffset="0dp">
910

1011
<LinearLayout
1112
android:layout_width="match_parent"

demo/src/main/res/layout/recyclerview_item.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
android:id="@+id/swipe"
88
android:layout_width="match_parent"
99
android:layout_height="wrap_content"
10-
swipe:horizontalSwipeOffset="0dp">
10+
swipe:leftEdgeSwipeOffset="0dp"
11+
swipe:rightEdgeSwipeOffset="0dp">
1112

1213
<LinearLayout
1314
android:layout_width="match_parent"

demo/src/main/res/layout/sample1.xml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
44
android:background="@drawable/item_selector"
5-
android:layout_width="match_parent" android:layout_height="80dp">
5+
android:layout_width="match_parent"
6+
android:layout_height="80dp">
7+
68
<LinearLayout
79
android:tag="Bottom1"
810
android:background="#66ddff00"
911
android:id="@+id/bottom_wrapper"
1012
android:layout_width="160dp"
1113
android:weightSum="1"
1214
android:layout_height="match_parent">
15+
1316
<TextView
1417
android:id="@+id/archive"
1518
android:textColor="#fff"
@@ -19,6 +22,7 @@
1922
android:background="#FF1300"
2023
android:layout_width="wrap_content"
2124
android:layout_height="match_parent" />
25+
2226
<TextView
2327
android:id="@+id/delete"
2428
android:text="Delete"
@@ -29,15 +33,71 @@
2933
android:layout_height="match_parent" />
3034
</LinearLayout>
3135

36+
<LinearLayout
37+
android:tag="Bottom4"
38+
android:id="@+id/bottom_wrapper_2"
39+
android:layout_width="wrap_content"
40+
android:layout_height="match_parent">
41+
42+
<ImageView
43+
android:id="@+id/magnifier2"
44+
android:src="@drawable/magnifier"
45+
android:layout_width="70dp"
46+
android:background="#f7e79c"
47+
android:paddingLeft="25dp"
48+
android:paddingRight="25dp"
49+
android:layout_height="match_parent" />
50+
51+
<ImageView
52+
android:id="@+id/star2"
53+
android:src="@drawable/star"
54+
android:layout_width="70dp"
55+
android:background="#4cd964"
56+
android:paddingLeft="25dp"
57+
android:paddingRight="25dp"
58+
android:layout_height="match_parent" />
59+
60+
<ImageView
61+
android:id="@+id/trash2"
62+
android:src="@drawable/trash"
63+
android:layout_width="70dp"
64+
android:background="#FF3B30"
65+
android:paddingLeft="25dp"
66+
android:paddingRight="25dp"
67+
android:layout_height="match_parent" />
68+
</LinearLayout>
69+
70+
<LinearLayout
71+
android:tag="Bottom3"
72+
android:id="@+id/starbott"
73+
android:layout_width="match_parent"
74+
android:layout_height="match_parent">
75+
<RelativeLayout
76+
android:id="@+id/bottom_wrapper_child1"
77+
android:background="#BDBEC2"
78+
android:layout_width="match_parent"
79+
android:layout_height="match_parent">
80+
<ImageView
81+
android:id="@+id/star"
82+
android:layout_alignParentTop="true"
83+
android:layout_centerHorizontal="true"
84+
android:src="@drawable/star"
85+
android:layout_width="20dp"
86+
android:layout_height="20dp" />
87+
</RelativeLayout>
88+
</LinearLayout>
89+
3290
<LinearLayout
3391
android:padding="10dp"
3492
android:background="#ffffff"
3593
android:layout_width="match_parent"
3694
android:layout_height="match_parent">
95+
3796
<TextView
3897
android:tag="Hover"
3998
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
4099
android:layout_width="match_parent"
41100
android:layout_height="match_parent" />
42101
</LinearLayout>
102+
43103
</com.daimajia.swipe.SwipeLayout>

0 commit comments

Comments
 (0)