Skip to content

Commit ae890a8

Browse files
committed
complicated nested support, listview, gridview open item close item support
1 parent 1ca8c4f commit ae890a8

File tree

9 files changed

+91
-52
lines changed

9 files changed

+91
-52
lines changed

demo/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</activity>
1919
<activity android:name="com.daimajia.swipedemo.ListViewExample"/>
2020
<activity android:name="com.daimajia.swipedemo.GridViewExample"/>
21+
<activity android:name=".NestedExample"/>
2122
</application>
2223

2324
</manifest>

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5-
import android.os.Handler;
65
import android.util.Log;
76
import android.view.View;
87
import android.widget.AdapterView;
@@ -49,28 +48,5 @@ public void onNothingSelected(AdapterView<?> parent) {
4948
}
5049
});
5150

52-
Handler handler = (new Handler());
53-
// Open up some items in the list
54-
handler.postDelayed(new Runnable() {
55-
@Override
56-
public void run() {
57-
adapter.openItem(1);
58-
adapter.openItem(2);
59-
adapter.openItem(3);
60-
adapter.openItem(1);
61-
}
62-
}, 1000);
63-
64-
65-
// Close some items in the list
66-
handler.postDelayed(new Runnable() {
67-
@Override
68-
public void run() {
69-
adapter.closeItem(1);
70-
adapter.closeItem(1);
71-
adapter.closeItem(3);
72-
}
73-
}, 3000);
74-
7551
}
7652
}

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.app.Activity;
44
import android.content.Intent;
55
import android.os.Bundle;
6-
import android.os.Handler;
76
import android.util.Log;
87
import android.view.Menu;
98
import android.view.MenuItem;
@@ -74,30 +73,6 @@ public void onNothingSelected(AdapterView<?> parent) {
7473
}
7574
});
7675

77-
final Handler handler = (new Handler());
78-
mPositionToTest = 0;
79-
Runnable runnable = new Runnable() {
80-
@Override
81-
public void run() {
82-
mAdapter.openItem(mPositionToTest++);
83-
if(mPositionToTest < 5)
84-
handler.postDelayed(this, 1000);
85-
}
86-
};
87-
// Open up some items in the list
88-
handler.postDelayed(runnable, 1000);
89-
90-
91-
// Close some items in the list
92-
handler.postDelayed(new Runnable() {
93-
@Override
94-
public void run() {
95-
mAdapter.closeItem(1);
96-
mAdapter.closeItem(4);
97-
mAdapter.closeItem(4);
98-
}
99-
}, 8000);
100-
10176
}
10277

10378

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
120120
} else if (id == R.id.action_gridview) {
121121
startActivity(new Intent(this, GridViewExample.class));
122122
return true;
123+
} else if(id == R.id.action_nexted){
124+
startActivity(new Intent(this, NestedExample.class));
125+
return true;
123126
}
124127
return super.onOptionsItemSelected(item);
125128
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.daimajia.swipedemo;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
import android.view.View;
7+
8+
public class NestedExample extends Activity{
9+
@Override
10+
protected void onCreate(Bundle savedInstanceState) {
11+
super.onCreate(savedInstanceState);
12+
setContentView(R.layout.nested);
13+
findViewById(R.id.hhhhh).setOnClickListener(new View.OnClickListener() {
14+
@Override
15+
public void onClick(View v) {
16+
Log.e("Tag","got");
17+
}
18+
});
19+
}
20+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent" android:layout_height="80dp">
5+
6+
<LinearLayout
7+
android:tag="Bottom3"
8+
android:layout_width="80dp"
9+
android:layout_height="match_parent">
10+
<ScrollView
11+
android:layout_width="match_parent"
12+
android:scrollbars="vertical"
13+
android:layout_height="wrap_content">
14+
<TextView
15+
android:tag="Hover"
16+
android:text="None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew. "
17+
android:layout_width="match_parent"
18+
android:layout_height="match_parent" />
19+
</ScrollView>
20+
</LinearLayout>
21+
22+
<LinearLayout
23+
android:padding="10dp"
24+
android:background="#ffffff"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent">
27+
<TextView
28+
android:text="Test ScrollView"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content" />
31+
<ScrollView
32+
android:layout_marginLeft="80dp"
33+
android:layout_width="match_parent"
34+
android:scrollbars="horizontal"
35+
android:layout_height="match_parent">
36+
<LinearLayout
37+
android:orientation="vertical"
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content">
40+
<TextView
41+
android:tag="Hover"
42+
android:text="None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew. "
43+
android:layout_width="match_parent"
44+
android:layout_height="match_parent" />
45+
<Button
46+
android:id="@+id/hhhhh"
47+
android:text="HelloWorld"
48+
android:layout_width="wrap_content"
49+
android:layout_height="wrap_content" />
50+
</LinearLayout>
51+
52+
</ScrollView>
53+
</LinearLayout>
54+
</com.daimajia.swipe.SwipeLayout>

demo/src/main/res/menu/my.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
android:title="GridView"
1010
android:orderInCategory="100"
1111
/>
12+
<item android:id="@+id/action_nexted"
13+
android:title="Nested"/>
1214
</menu>

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# org.gradle.parallel=true
1919

2020

21-
VERSION_NAME=1.0.4
22-
VERSION_CODE=4
21+
VERSION_NAME=1.0.5
22+
VERSION_CODE=6
2323
GROUP=com.daimajia.swipelayout
2424

2525
ANDROID_BUILD_MIN_SDK_VERSION=14

library/src/main/java/com/daimajia/swipe/SwipeLayout.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,17 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
653653
//then let it do it.
654654
//
655655
int action = ev.getActionMasked();
656+
Status status = getOpenStatus();
656657
switch (action){
657658
case MotionEvent.ACTION_DOWN:
658-
View child = childNeed(getSurfaceView(), ev);
659+
View child;
660+
if(status == Status.Close){
661+
child = childNeed(getSurfaceView(), ev);
662+
}else if(status == Status.Open){
663+
child = childNeed(getBottomView(), ev);
664+
}else{
665+
break;
666+
}
659667
if(child != null){
660668
childNeeded = child;
661669
return false;

0 commit comments

Comments
 (0)