complicated nested support, listview, gridview open item close item support
This commit is contained in:
parent
1ca8c4f049
commit
ae890a8c9a
|
|
@ -18,6 +18,7 @@
|
|||
</activity>
|
||||
<activity android:name="com.daimajia.swipedemo.ListViewExample"/>
|
||||
<activity android:name="com.daimajia.swipedemo.GridViewExample"/>
|
||||
<activity android:name=".NestedExample"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.daimajia.swipedemo;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
|
@ -49,28 +48,5 @@ public class GridViewExample extends Activity{
|
|||
}
|
||||
});
|
||||
|
||||
Handler handler = (new Handler());
|
||||
// Open up some items in the list
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.openItem(1);
|
||||
adapter.openItem(2);
|
||||
adapter.openItem(3);
|
||||
adapter.openItem(1);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
|
||||
// Close some items in the list
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.closeItem(1);
|
||||
adapter.closeItem(1);
|
||||
adapter.closeItem(3);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.daimajia.swipedemo;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -74,30 +73,6 @@ public class ListViewExample extends Activity {
|
|||
}
|
||||
});
|
||||
|
||||
final Handler handler = (new Handler());
|
||||
mPositionToTest = 0;
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAdapter.openItem(mPositionToTest++);
|
||||
if(mPositionToTest < 5)
|
||||
handler.postDelayed(this, 1000);
|
||||
}
|
||||
};
|
||||
// Open up some items in the list
|
||||
handler.postDelayed(runnable, 1000);
|
||||
|
||||
|
||||
// Close some items in the list
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAdapter.closeItem(1);
|
||||
mAdapter.closeItem(4);
|
||||
mAdapter.closeItem(4);
|
||||
}
|
||||
}, 8000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@ public class MyActivity extends Activity {
|
|||
} else if (id == R.id.action_gridview) {
|
||||
startActivity(new Intent(this, GridViewExample.class));
|
||||
return true;
|
||||
} else if(id == R.id.action_nexted){
|
||||
startActivity(new Intent(this, NestedExample.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.daimajia.swipedemo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
public class NestedExample extends Activity{
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nested);
|
||||
findViewById(R.id.hhhhh).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.e("Tag","got");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="80dp">
|
||||
|
||||
<LinearLayout
|
||||
android:tag="Bottom3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent">
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:tag="Hover"
|
||||
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. "
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="Test ScrollView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<ScrollView
|
||||
android:layout_marginLeft="80dp"
|
||||
android:layout_width="match_parent"
|
||||
android:scrollbars="horizontal"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:tag="Hover"
|
||||
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. "
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<Button
|
||||
android:id="@+id/hhhhh"
|
||||
android:text="HelloWorld"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -9,4 +9,6 @@
|
|||
android:title="GridView"
|
||||
android:orderInCategory="100"
|
||||
/>
|
||||
<item android:id="@+id/action_nexted"
|
||||
android:title="Nested"/>
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
# org.gradle.parallel=true
|
||||
|
||||
|
||||
VERSION_NAME=1.0.4
|
||||
VERSION_CODE=4
|
||||
VERSION_NAME=1.0.5
|
||||
VERSION_CODE=6
|
||||
GROUP=com.daimajia.swipelayout
|
||||
|
||||
ANDROID_BUILD_MIN_SDK_VERSION=14
|
||||
|
|
|
|||
|
|
@ -653,9 +653,17 @@ public class SwipeLayout extends FrameLayout {
|
|||
//then let it do it.
|
||||
//
|
||||
int action = ev.getActionMasked();
|
||||
Status status = getOpenStatus();
|
||||
switch (action){
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
View child = childNeed(getSurfaceView(), ev);
|
||||
View child;
|
||||
if(status == Status.Close){
|
||||
child = childNeed(getSurfaceView(), ev);
|
||||
}else if(status == Status.Open){
|
||||
child = childNeed(getBottomView(), ev);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
if(child != null){
|
||||
childNeeded = child;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue