Skip to content

Commit feafd6a

Browse files
committed
Merge branch 'master' of https://github.com/linfaxin/AndroidSwipeLayout into linfaxin
2 parents 3041765 + 79bb4ec commit feafd6a

File tree

14 files changed

+665
-659
lines changed

14 files changed

+665
-659
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public boolean onTouch(View v, MotionEvent event) {
6868
@Override
6969
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
7070
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
71-
return false;
71+
return true;
7272
}
7373
});
7474
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Intent;
55
import android.graphics.Color;
66
import android.os.Bundle;
7+
import android.util.Log;
78
import android.view.Menu;
89
import android.view.MenuItem;
910
import android.view.View;
@@ -28,16 +29,31 @@ protected void onCreate(Bundle savedInstanceState) {
2829

2930
sample1 = (SwipeLayout) findViewById(R.id.sample1);
3031
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
31-
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
32+
// sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
3233
// 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);
34+
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, R.id.starbott);
3435
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
3536
@Override
3637
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
3738

3839
}
3940
});
4041

42+
sample1.getSurfaceView().setOnClickListener(new View.OnClickListener() {
43+
@Override
44+
public void onClick(View v) {
45+
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
46+
Log.d(MyActivity.class.getName(), "click on surface");
47+
}
48+
});
49+
sample1.getSurfaceView().setOnLongClickListener(new View.OnLongClickListener() {
50+
@Override
51+
public boolean onLongClick(View v) {
52+
Toast.makeText(MyActivity.this, "longClick on surface", Toast.LENGTH_SHORT).show();
53+
Log.d(MyActivity.class.getName(), "longClick on surface");
54+
return true;
55+
}
56+
});
4157
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
4258
@Override
4359
public void onClick(View v) {
@@ -103,6 +119,12 @@ public void onClick(View v) {
103119
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
104120
}
105121
});
122+
sample2.getSurfaceView().setOnClickListener(new View.OnClickListener() {
123+
@Override
124+
public void onClick(View v) {
125+
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
126+
}
127+
});
106128

107129
//sample3
108130

@@ -120,12 +142,18 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
120142
child.setBackgroundColor(c);
121143
}
122144
});
123-
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
145+
sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {
124146
@Override
125147
public void onClick(View v) {
126148
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
127149
}
128150
});
151+
sample3.getSurfaceView().setOnClickListener(new View.OnClickListener() {
152+
@Override
153+
public void onClick(View v) {
154+
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
155+
}
156+
});
129157

130158
}
131159

demo/src/main/java/com/daimajia/swipedemo/adapter/ListViewAdapter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public void onDoubleClick(SwipeLayout layout, boolean surface) {
4343
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
4444
}
4545
});
46+
v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
47+
@Override
48+
public void onClick(View view) {
49+
Toast.makeText(mContext, "click delete", Toast.LENGTH_SHORT).show();
50+
}
51+
});
4652
return v;
4753
}
4854

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:drawable="@color/dark_gray_press" android:state_pressed="true"/>
5+
<item android:drawable="@color/dark_gray_press" android:state_focused="true"/>
6+
<item android:drawable="@color/dark_gray"/>
7+
8+
</selector>

demo/src/main/res/drawable/red.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:drawable="@color/red_press" android:state_pressed="true"/>
5+
<item android:drawable="@color/red_press" android:state_focused="true"/>
6+
<item android:drawable="@color/red"/>
7+
8+
</selector>

demo/src/main/res/drawable/white.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:drawable="@android:color/darker_gray" android:state_pressed="true"/>
5+
<item android:drawable="@android:color/darker_gray" android:state_focused="true"/>
6+
<item android:drawable="@android:color/white"/>
7+
8+
</selector>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:layout_width="0dp"
3737
android:layout_height="40dp"
3838
android:layout_weight="4"
39-
android:background="#ffffff"
39+
android:background="@drawable/white"
4040
android:text="Yes,Delete"
4141
android:textColor="#FF5534" />
4242
</LinearLayout>

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
32
<com.daimajia.swipe.SwipeLayout
43
xmlns:android="http://schemas.android.com/apk/res/android"
5-
xmlns:app="http://schemas.android.com/apk/res-auto"
64
android:id="@+id/godfather"
7-
android:layout_width="match_parent" android:layout_height="match_parent"
8-
app:drag_edge="bottom">
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
<ImageView
8+
android:layout_gravity="left|right|top"
9+
android:src="@drawable/bird"
10+
android:layout_width="100dp"
11+
android:layout_height="100dp" />
912
<LinearLayout
13+
android:id="@+id/bird_bottom"
14+
android:layout_gravity="bottom"
1015
android:gravity="center"
1116
android:layout_width="match_parent"
1217
android:layout_height="match_parent">

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:background="@drawable/item_selector"
3+
<com.daimajia.swipe.SwipeLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
56
android:layout_width="match_parent"
6-
android:layout_height="80dp">
7+
android:layout_height="80dp"
8+
app:clickToClose="true">
79

810
<LinearLayout
911
android:tag="Bottom1"
@@ -19,7 +21,8 @@
1921
android:text="Archive"
2022
android:layout_weight="0.5"
2123
android:gravity="center"
22-
android:background="#FF1300"
24+
android:clickable="true"
25+
android:background="@drawable/red"
2326
android:layout_width="wrap_content"
2427
android:layout_height="match_parent" />
2528

@@ -61,7 +64,7 @@
6164
android:id="@+id/trash2"
6265
android:src="@drawable/trash"
6366
android:layout_width="70dp"
64-
android:background="#FF3B30"
67+
android:background="@drawable/red"
6568
android:paddingLeft="25dp"
6669
android:paddingRight="25dp"
6770
android:layout_height="match_parent" />
@@ -74,7 +77,8 @@
7477
android:layout_height="match_parent">
7578
<RelativeLayout
7679
android:id="@+id/bottom_wrapper_child1"
77-
android:background="#4C535B"
80+
android:background="@drawable/dark_gray"
81+
android:clickable="true"
7882
android:layout_width="match_parent"
7983
android:layout_height="match_parent">
8084
<ImageView
@@ -87,17 +91,12 @@
8791
</RelativeLayout>
8892
</LinearLayout>
8993

90-
<LinearLayout
94+
<TextView
9195
android:padding="10dp"
92-
android:background="#ffffff"
96+
android:background="@drawable/white"
97+
android:tag="Hover"
98+
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
9399
android:layout_width="match_parent"
94-
android:layout_height="match_parent">
95-
96-
<TextView
97-
android:tag="Hover"
98-
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
99-
android:layout_width="match_parent"
100-
android:layout_height="match_parent" />
101-
</LinearLayout>
100+
android:layout_height="match_parent" />
102101

103102
</com.daimajia.swipe.SwipeLayout>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:id="@+id/trash"
2727
android:src="@drawable/trash"
2828
android:layout_width="70dp"
29-
android:background="#FF3B30"
29+
android:background="@drawable/red"
3030
android:paddingLeft="25dp"
3131
android:paddingRight="25dp"
3232
android:layout_height="match_parent" />
@@ -35,7 +35,7 @@
3535
<LinearLayout
3636
android:padding="10dp"
3737
android:orientation="vertical"
38-
android:background="#ffffff"
38+
android:background="@drawable/white"
3939
android:layout_width="match_parent"
4040
android:layout_height="match_parent">
4141
<TextView

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
</RelativeLayout>
2323
</LinearLayout>
2424

25-
<LinearLayout
25+
<TextView
2626
android:padding="10dp"
2727
android:background="#ffffff"
28+
android:tag="Hover"
29+
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
2830
android:layout_width="match_parent"
29-
android:layout_height="match_parent">
30-
<TextView
31-
android:tag="Hover"
32-
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
33-
android:layout_width="match_parent"
34-
android:layout_height="match_parent" />
35-
</LinearLayout>
31+
android:layout_height="match_parent" />
3632
</com.daimajia.swipe.SwipeLayout>

demo/src/main/res/values/colors.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
<resources>
33
<color name="backgroundColor">#E8E8E0</color>
44
<color name="backgroundColorPress">#DBDBD3</color>
5+
<color name="red">#FF3B00</color>
6+
<color name="red_press">#990000</color>
7+
<color name="dark_gray">#4C535B</color>
8+
<color name="dark_gray_press">#ff7e8a97</color>
59
</resources>

0 commit comments

Comments
 (0)