Merge pull request #93 from HarshEvilGeek/master

Adding support for multiple drag edges on a single view and touchSlop
This commit is contained in:
代码家 2015-02-22 11:44:02 +08:00
commit 19079c76cb
7 changed files with 821 additions and 442 deletions

View File

@ -7,7 +7,6 @@ repositories {
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)

View File

@ -27,8 +27,10 @@ public class MyActivity extends Activity {
//sample1
sample1 = (SwipeLayout) findViewById(R.id.sample1);
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
sample1.setDragEdge(SwipeLayout.DragEdge.Left);
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
// 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)
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT);
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
@Override
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
@ -36,10 +38,32 @@ public class MyActivity extends Activity {
}
});
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
}
});
sample1.findViewById(R.id.trash2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
}
});
sample1.findViewById(R.id.magnifier2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
}
});
//sample2
sample2 = (SwipeLayout) findViewById(R.id.sample2);
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
sample2.setDragEdge(SwipeLayout.DragEdge.Right);
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -5,7 +5,8 @@
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
swipe:horizontalSwipeOffset="0dp">
swipe:leftEdgeSwipeOffset="0dp"
swipe:rightEdgeSwipeOffset="0dp">
<LinearLayout
android:layout_width="match_parent"

View File

@ -7,7 +7,8 @@
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
swipe:horizontalSwipeOffset="0dp">
swipe:leftEdgeSwipeOffset="0dp"
swipe:rightEdgeSwipeOffset="0dp">
<LinearLayout
android:layout_width="match_parent"

View File

@ -2,7 +2,9 @@
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/item_selector"
android:layout_width="match_parent" android:layout_height="80dp">
android:layout_width="match_parent"
android:layout_height="80dp">
<LinearLayout
android:tag="Bottom1"
android:background="#66ddff00"
@ -10,6 +12,7 @@
android:layout_width="160dp"
android:weightSum="1"
android:layout_height="match_parent">
<TextView
android:id="@+id/archive"
android:textColor="#fff"
@ -19,6 +22,7 @@
android:background="#FF1300"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<TextView
android:id="@+id/delete"
android:text="Delete"
@ -29,15 +33,71 @@
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:tag="Bottom4"
android:id="@+id/bottom_wrapper_2"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/magnifier2"
android:src="@drawable/magnifier"
android:layout_width="70dp"
android:background="#f7e79c"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/star2"
android:src="@drawable/star"
android:layout_width="70dp"
android:background="#4cd964"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/trash2"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="#FF3B30"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:tag="Bottom3"
android:id="@+id/starbott"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/bottom_wrapper_child1"
android:background="#BDBEC2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/star"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/star"
android:layout_width="20dp"
android:layout_height="20dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:padding="10dp"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:tag="Hover"
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeLayout">
<attr name="drag_edge" format="enum">
<enum name="left" value="0"/>
<enum name="right" value="1"/>
<enum name="top" value="2"/>
<enum name="bottom" value="3"/>
<attr name="drag_edge">
<flag name="left" value="1" />
<flag name="right" value="2" />
<flag name="top" value="4" />
<flag name="bottom" value="8" />
</attr>
<attr name="horizontalSwipeOffset" format="dimension"/>
<attr name="verticalSwipeOffset" format="dimension"/>
<attr name="leftEdgeSwipeOffset" format="dimension" />
<attr name="rightEdgeSwipeOffset" format="dimension" />
<attr name="topEdgeSwipeOffset" format="dimension" />
<attr name="bottomEdgeSwipeOffset" format="dimension" />
<attr name="show_mode" format="enum">
<enum name="lay_down" value="0"/>
<enum name="pull_out" value="1"/>
<enum name="lay_down" value="0" />
<enum name="pull_out" value="1" />
</attr>
</declare-styleable>
</resources>