Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean onTouch(View v, MotionEvent event) {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
return false;
return true;
}
});
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
Expand Down
34 changes: 31 additions & 3 deletions demo/src/main/java/com/daimajia/swipedemo/MyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -28,16 +29,31 @@ protected void onCreate(Bundle savedInstanceState) {

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

}
});

sample1.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "click on surface");
}
});
sample1.getSurfaceView().setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MyActivity.this, "longClick on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "longClick on surface");
return true;
}
});
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -103,6 +119,12 @@ public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
}
});
sample2.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});

//sample3

Expand All @@ -120,12 +142,18 @@ public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int
child.setBackgroundColor(c);
}
});
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
}
});
sample3.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public void onDoubleClick(SwipeLayout layout, boolean surface) {
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
}
});
v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "click delete", Toast.LENGTH_SHORT).show();
}
});
return v;
}

Expand Down
8 changes: 8 additions & 0 deletions demo/src/main/res/drawable/dark_gray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/dark_gray_press" android:state_pressed="true"/>
<item android:drawable="@color/dark_gray_press" android:state_focused="true"/>
<item android:drawable="@color/dark_gray"/>

</selector>
8 changes: 8 additions & 0 deletions demo/src/main/res/drawable/red.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/red_press" android:state_pressed="true"/>
<item android:drawable="@color/red_press" android:state_focused="true"/>
<item android:drawable="@color/red"/>

</selector>
8 changes: 8 additions & 0 deletions demo/src/main/res/drawable/white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@android:color/darker_gray" android:state_pressed="true"/>
<item android:drawable="@android:color/darker_gray" android:state_focused="true"/>
<item android:drawable="@android:color/white"/>

</selector>
2 changes: 1 addition & 1 deletion demo/src/main/res/layout/listview_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:background="#ffffff"
android:background="@drawable/white"
android:text="Yes,Delete"
android:textColor="#FF5534" />
</LinearLayout>
Expand Down
13 changes: 9 additions & 4 deletions demo/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>

<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/godfather"
android:layout_width="match_parent" android:layout_height="match_parent"
app:drag_edge="bottom">
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_gravity="left|right|top"
android:src="@drawable/bird"
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:id="@+id/bird_bottom"
android:layout_gravity="bottom"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down
31 changes: 15 additions & 16 deletions demo/src/main/res/layout/sample1.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/item_selector"
<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp">
android:layout_height="80dp"
app:clickToClose="true">

<LinearLayout
android:tag="Bottom1"
Expand All @@ -19,7 +21,8 @@
android:text="Archive"
android:layout_weight="0.5"
android:gravity="center"
android:background="#FF1300"
android:clickable="true"
android:background="@drawable/red"
android:layout_width="wrap_content"
android:layout_height="match_parent" />

Expand Down Expand Up @@ -61,7 +64,7 @@
android:id="@+id/trash2"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="#FF3B30"
android:background="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
Expand All @@ -74,7 +77,8 @@
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/bottom_wrapper_child1"
android:background="#4C535B"
android:background="@drawable/dark_gray"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
Expand All @@ -87,17 +91,12 @@
</RelativeLayout>
</LinearLayout>

<LinearLayout
<TextView
android:padding="10dp"
android:background="#ffffff"
android:background="@drawable/white"
android:tag="Hover"
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
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>
android:layout_height="match_parent" />

</com.daimajia.swipe.SwipeLayout>
4 changes: 2 additions & 2 deletions demo/src/main/res/layout/sample2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:id="@+id/trash"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="#FF3B30"
android:background="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
Expand All @@ -35,7 +35,7 @@
<LinearLayout
android:padding="10dp"
android:orientation="vertical"
android:background="#ffffff"
android:background="@drawable/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
Expand Down
12 changes: 4 additions & 8 deletions demo/src/main/res/layout/sample3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
</RelativeLayout>
</LinearLayout>

<LinearLayout
<TextView
android:padding="10dp"
android:background="#ffffff"
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
android:layout_height="match_parent" />
</com.daimajia.swipe.SwipeLayout>
4 changes: 4 additions & 0 deletions demo/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
<resources>
<color name="backgroundColor">#E8E8E0</color>
<color name="backgroundColorPress">#DBDBD3</color>
<color name="red">#FF3B00</color>
<color name="red_press">#990000</color>
<color name="dark_gray">#4C535B</color>
<color name="dark_gray_press">#ff7e8a97</color>
</resources>
Loading