Compare commits
43 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
5f8678b047 | |
|
|
cf179b1270 | |
|
|
2d6d44fb93 | |
|
|
85adc4a022 | |
|
|
4e55a83a73 | |
|
|
91dddd3b5a | |
|
|
564a74fcc7 | |
|
|
d7a5759784 | |
|
|
be4a2c7c84 | |
|
|
f66ac6942b | |
|
|
eab20af25d | |
|
|
14b67ac74a | |
|
|
6f6498e549 | |
|
|
a10e28ded7 | |
|
|
bfd86f0a6f | |
|
|
a3ca6ca713 | |
|
|
0734b92f88 | |
|
|
5ade0f2d21 | |
|
|
cc6a322f74 | |
|
|
be8b5d483e | |
|
|
e82cf4b21a | |
|
|
9a0bb05a5c | |
|
|
cc1d1b3b71 | |
|
|
32bc0a5640 | |
|
|
f53ccb009c | |
|
|
84001f59f6 | |
|
|
5ffd6a2e2b | |
|
|
b68a08c641 | |
|
|
66b0ef3ae8 | |
|
|
ca792b5166 | |
|
|
f9ac392ef6 | |
|
|
0e0390c1ff | |
|
|
670863a2d5 | |
|
|
feafd6a835 | |
|
|
3041765187 | |
|
|
72612ad687 | |
|
|
79bb4ecb36 | |
|
|
b460d4dd47 | |
|
|
8fea955083 | |
|
|
8412d50131 | |
|
|
6e909b0343 | |
|
|
8e89db06b0 | |
|
|
742494d085 |
|
|
@ -0,0 +1,12 @@
|
||||||
|
language: android
|
||||||
|
android:
|
||||||
|
components:
|
||||||
|
- tools
|
||||||
|
- platform-tools
|
||||||
|
- build-tools-25.0.2
|
||||||
|
- android-25
|
||||||
|
- extra-android-support
|
||||||
|
- extra
|
||||||
|
- extra-android-m2repository
|
||||||
|
script:
|
||||||
|
- ./gradlew assembleDebug
|
||||||
10
README.md
10
README.md
|
|
@ -1,7 +1,9 @@
|
||||||
# Android Swipe Layout
|
# Android Swipe Layout [](https://travis-ci.org/daimajia/AndroidSwipeLayout)
|
||||||
|
|
||||||
[](https://gitter.im/daimajia/AndroidSwipeLayout?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/daimajia/AndroidSwipeLayout?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
[](https://insight.io/github.com/daimajia/AndroidSwipeLayout)
|
||||||
|
|
||||||
This is the brother of [AndroidViewHover](https://github.com/daimajia/AndroidViewHover).
|
This is the brother of [AndroidViewHover](https://github.com/daimajia/AndroidViewHover).
|
||||||
|
|
||||||
One year ago, I started to make an app named [EverMemo](https://play.google.com/store/apps/details?id=com.zhan_dui.evermemo) with my good friends. The designer gave me a design picture, the design like this:
|
One year ago, I started to make an app named [EverMemo](https://play.google.com/store/apps/details?id=com.zhan_dui.evermemo) with my good friends. The designer gave me a design picture, the design like this:
|
||||||
|
|
@ -40,7 +42,7 @@ When I start to make this library, I set some goals:
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:recyclerview-v7:21.0.0'
|
compile 'com.android.support:recyclerview-v7:21.0.0'
|
||||||
compile 'com.android.support:support-v4:20.+'
|
compile 'com.android.support:support-v4:20.+'
|
||||||
compile "com.daimajia.swipelayout:library:1.1.8@aar"
|
compile "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -60,7 +62,7 @@ dependencies {
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.daimajia.swipelayout</groupId>
|
<groupId>com.daimajia.swipelayout</groupId>
|
||||||
<artifactId>library</artifactId>
|
<artifactId>library</artifactId>
|
||||||
<version>1.1.8</version>
|
<version>1.2.0</version>
|
||||||
<type>apklib</type>
|
<type>apklib</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
@ -71,6 +73,8 @@ dependencies {
|
||||||
|
|
||||||
### Step 2
|
### Step 2
|
||||||
|
|
||||||
|
**Make sure to use the internal adapter instead of your own!**
|
||||||
|
|
||||||
[Wiki Usage](https://github.com/daimajia/AndroidSwipeLayout/wiki/usage)
|
[Wiki Usage](https://github.com/daimajia/AndroidSwipeLayout/wiki/usage)
|
||||||
|
|
||||||
## Wiki
|
## Wiki
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,13 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||||
|
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
@ -15,5 +19,8 @@ buildscript {
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":library")
|
compile project(":library")
|
||||||
compile 'com.android.support:recyclerview-v7:21.0.0'
|
compile 'com.android.support:recyclerview-v7:25.1.1'
|
||||||
compile 'com.daimajia.easing:library:1.0.0@aar'
|
compile 'com.daimajia.easing:library:1.0.0@aar'
|
||||||
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
|
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
|
||||||
compile 'com.nineoldandroids:library:2.4.0'
|
compile 'com.nineoldandroids:library:2.4.0'
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
|
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
import com.daimajia.swipedemo.adapter.GridViewAdapter;
|
import com.daimajia.swipedemo.adapter.GridViewAdapter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
import com.daimajia.swipedemo.adapter.ListViewAdapter;
|
import com.daimajia.swipedemo.adapter.ListViewAdapter;
|
||||||
|
|
||||||
|
|
@ -68,7 +67,7 @@ public class ListViewExample extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -28,9 +29,11 @@ public class MyActivity extends Activity {
|
||||||
|
|
||||||
sample1 = (SwipeLayout) findViewById(R.id.sample1);
|
sample1 = (SwipeLayout) findViewById(R.id.sample1);
|
||||||
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
|
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||||
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
|
View starBottView = sample1.findViewById(R.id.starbott);
|
||||||
// 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.addDrag(SwipeLayout.DragEdge.Left, sample1.findViewById(R.id.bottom_wrapper));
|
||||||
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT);
|
sample1.addDrag(SwipeLayout.DragEdge.Right, sample1.findViewById(R.id.bottom_wrapper_2));
|
||||||
|
sample1.addDrag(SwipeLayout.DragEdge.Top, starBottView);
|
||||||
|
sample1.addDrag(SwipeLayout.DragEdge.Bottom, starBottView);
|
||||||
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
|
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||||
|
|
@ -38,6 +41,21 @@ public class MyActivity extends Activity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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() {
|
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
@ -74,7 +92,7 @@ public class MyActivity extends Activity {
|
||||||
|
|
||||||
sample2 = (SwipeLayout) findViewById(R.id.sample2);
|
sample2 = (SwipeLayout) findViewById(R.id.sample2);
|
||||||
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
|
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||||
sample2.setDragEdge(SwipeLayout.DragEdge.Right);
|
sample2.addDrag(SwipeLayout.DragEdge.Right, sample2.findViewWithTag("Bottom2"));
|
||||||
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
|
// sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||||
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -103,11 +121,17 @@ public class MyActivity extends Activity {
|
||||||
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
|
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
|
//sample3
|
||||||
|
|
||||||
sample3 = (SwipeLayout) findViewById(R.id.sample3);
|
sample3 = (SwipeLayout) findViewById(R.id.sample3);
|
||||||
sample3.setDragEdge(SwipeLayout.DragEdge.Top);
|
sample3.addDrag(SwipeLayout.DragEdge.Top, sample3.findViewWithTag("Bottom3"));
|
||||||
sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {
|
sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||||
|
|
@ -120,12 +144,18 @@ public class MyActivity extends Activity {
|
||||||
child.setBackgroundColor(c);
|
child.setBackgroundColor(c);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.daimajia.swipedemo;
|
||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@ public class ListViewAdapter extends BaseSwipeAdapter {
|
||||||
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import com.daimajia.androidanimations.library.YoYo;
|
||||||
import com.daimajia.swipe.SimpleSwipeListener;
|
import com.daimajia.swipe.SimpleSwipeListener;
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.adapters.RecyclerSwipeAdapter;
|
import com.daimajia.swipe.adapters.RecyclerSwipeAdapter;
|
||||||
import com.daimajia.swipe.implments.SwipeItemRecyclerMangerImpl;
|
|
||||||
import com.daimajia.swipedemo.R;
|
import com.daimajia.swipedemo.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -90,7 +89,7 @@ public class RecyclerViewAdapter extends RecyclerSwipeAdapter<RecyclerViewAdapte
|
||||||
});
|
});
|
||||||
viewHolder.textViewPos.setText((position + 1) + ".");
|
viewHolder.textViewPos.setText((position + 1) + ".");
|
||||||
viewHolder.textViewData.setText(item);
|
viewHolder.textViewData.setText(item);
|
||||||
mItemManger.bindView(viewHolder.itemView, position);
|
mItemManger.bind(viewHolder.itemView, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,9 @@ public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListen
|
||||||
@Override
|
@Override
|
||||||
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
|
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_weight="4"
|
android:layout_weight="4"
|
||||||
android:background="#ffffff"
|
android:background="@drawable/white"
|
||||||
android:text="Yes,Delete"
|
android:text="Yes,Delete"
|
||||||
android:textColor="#FF5534" />
|
android:textColor="#FF5534" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<com.daimajia.swipe.SwipeLayout
|
<com.daimajia.swipe.SwipeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/godfather"
|
android:id="@+id/godfather"
|
||||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:drag_edge="bottom">
|
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
|
<LinearLayout
|
||||||
|
android:id="@+id/bird_bottom"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.daimajia.swipe.SwipeLayout
|
||||||
android:background="@drawable/item_selector"
|
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_width="match_parent"
|
||||||
android:layout_height="80dp">
|
android:layout_height="80dp"
|
||||||
|
app:clickToClose="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:tag="Bottom1"
|
android:tag="Bottom1"
|
||||||
|
|
@ -19,7 +21,8 @@
|
||||||
android:text="Archive"
|
android:text="Archive"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="#FF1300"
|
android:clickable="true"
|
||||||
|
android:background="@drawable/red"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
@ -61,7 +64,7 @@
|
||||||
android:id="@+id/trash2"
|
android:id="@+id/trash2"
|
||||||
android:src="@drawable/trash"
|
android:src="@drawable/trash"
|
||||||
android:layout_width="70dp"
|
android:layout_width="70dp"
|
||||||
android:background="#FF3B30"
|
android:background="@drawable/red"
|
||||||
android:paddingLeft="25dp"
|
android:paddingLeft="25dp"
|
||||||
android:paddingRight="25dp"
|
android:paddingRight="25dp"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
@ -74,7 +77,8 @@
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/bottom_wrapper_child1"
|
android:id="@+id/bottom_wrapper_child1"
|
||||||
android:background="#4C535B"
|
android:background="@drawable/dark_gray"
|
||||||
|
android:clickable="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
@ -87,17 +91,12 @@
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:padding="10dp"
|
|
||||||
android:background="#ffffff"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:padding="10dp"
|
||||||
|
android:background="@drawable/white"
|
||||||
android:tag="Hover"
|
android:tag="Hover"
|
||||||
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
|
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.daimajia.swipe.SwipeLayout>
|
</com.daimajia.swipe.SwipeLayout>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
android:id="@+id/trash"
|
android:id="@+id/trash"
|
||||||
android:src="@drawable/trash"
|
android:src="@drawable/trash"
|
||||||
android:layout_width="70dp"
|
android:layout_width="70dp"
|
||||||
android:background="#FF3B30"
|
android:background="@drawable/red"
|
||||||
android:paddingLeft="25dp"
|
android:paddingLeft="25dp"
|
||||||
android:paddingRight="25dp"
|
android:paddingRight="25dp"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="#ffffff"
|
android:background="@drawable/white"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,11 @@
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:background="#ffffff"
|
android:background="#ffffff"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<TextView
|
|
||||||
android:tag="Hover"
|
android:tag="Hover"
|
||||||
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
|
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
</LinearLayout>
|
|
||||||
</com.daimajia.swipe.SwipeLayout>
|
</com.daimajia.swipe.SwipeLayout>
|
||||||
|
|
@ -2,4 +2,8 @@
|
||||||
<resources>
|
<resources>
|
||||||
<color name="backgroundColor">#E8E8E0</color>
|
<color name="backgroundColor">#E8E8E0</color>
|
||||||
<color name="backgroundColorPress">#DBDBD3</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>
|
</resources>
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
|
|
||||||
VERSION_NAME=1.1.8
|
VERSION_NAME=1.2.0
|
||||||
VERSION_CODE=20
|
VERSION_CODE=22
|
||||||
GROUP=com.daimajia.swipelayout
|
GROUP=com.daimajia.swipelayout
|
||||||
|
|
||||||
ANDROID_BUILD_MIN_SDK_VERSION=8
|
ANDROID_BUILD_MIN_SDK_VERSION=9
|
||||||
ANDROID_BUILD_TARGET_SDK_VERSION=21
|
ANDROID_BUILD_TARGET_SDK_VERSION=25
|
||||||
ANDROID_BUILD_SDK_VERSION=21
|
ANDROID_BUILD_SDK_VERSION=25
|
||||||
ANDROID_BUILD_TOOLS_VERSION=21.0.0
|
ANDROID_BUILD_TOOLS_VERSION=25.0.2
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#Wed Apr 10 15:27:10 PDT 2013
|
#Thu Mar 09 16:07:03 CST 2017
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,22 @@ android {
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 9
|
||||||
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
|
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:recyclerview-v7:21.0.0'
|
compile 'com.android.support:recyclerview-v7:25.2.0'
|
||||||
compile 'com.android.support:support-v4:21.0.3'
|
compile 'com.android.support:support-v4:25.2.0'
|
||||||
}
|
}
|
||||||
apply from: './gradle-mvn-push.gradle'
|
apply from: './gradle-mvn-push.gradle'
|
||||||
|
|
||||||
|
// build a jar with source files
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
from android.sourceSets.main.java.srcDirs
|
||||||
|
classifier = 'sources'
|
||||||
|
}
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
<manifest package="com.daimajia.swipe">
|
||||||
<manifest package="com.daimajia.swipe"/>
|
<application />
|
||||||
|
</manifest>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -6,7 +6,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemAdapterMangerImpl;
|
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
|
|
@ -14,9 +13,9 @@ import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class ArraySwipeAdapter<T> extends ArrayAdapter implements SwipeItemMangerInterface,SwipeAdapterInterface {
|
public abstract class ArraySwipeAdapter<T> extends ArrayAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
private SwipeItemAdapterMangerImpl mItemManger = new SwipeItemAdapterMangerImpl(this);
|
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
{}
|
{}
|
||||||
public ArraySwipeAdapter(Context context, int resource) {
|
public ArraySwipeAdapter(Context context, int resource) {
|
||||||
super(context, resource);
|
super(context, resource);
|
||||||
|
|
@ -43,14 +42,14 @@ public abstract class ArraySwipeAdapter<T> extends ArrayAdapter implements Swipe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public void notifyDatasetChanged() {
|
||||||
boolean convertViewIsNull = convertView == null;
|
super.notifyDataSetChanged();
|
||||||
View v = super.getView(position, convertView, parent);
|
|
||||||
if(convertViewIsNull){
|
|
||||||
mItemManger.initialize(v, position);
|
|
||||||
}else{
|
|
||||||
mItemManger.updateConvertView(v, position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View v = super.getView(position, convertView, parent);
|
||||||
|
mItemManger.bind(v, position);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,8 @@ import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemAdapterMangerImpl;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||||
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
|
|
@ -15,7 +14,7 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class BaseSwipeAdapter extends BaseAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class BaseSwipeAdapter extends BaseAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
protected SwipeItemAdapterMangerImpl mItemManger = new SwipeItemAdapterMangerImpl(this);
|
protected SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the {@link com.daimajia.swipe.SwipeLayout} resource id, int the view item.
|
* return the {@link com.daimajia.swipe.SwipeLayout} resource id, int the view item.
|
||||||
|
|
@ -42,16 +41,19 @@ public abstract class BaseSwipeAdapter extends BaseAdapter implements SwipeItemM
|
||||||
*/
|
*/
|
||||||
public abstract void fillValues(int position, View convertView);
|
public abstract void fillValues(int position, View convertView);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDatasetChanged() {
|
||||||
|
super.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final View getView(int position, View convertView, ViewGroup parent) {
|
public final View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
if(v == null){
|
if(v == null){
|
||||||
v = generateView(position, parent);
|
v = generateView(position, parent);
|
||||||
mItemManger.initialize(v, position);
|
|
||||||
}else{
|
|
||||||
mItemManger.updateConvertView(v, position);
|
|
||||||
}
|
}
|
||||||
|
mItemManger.bind(v, position);
|
||||||
fillValues(position, v);
|
fillValues(position, v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemAdapterMangerImpl;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||||
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
private SwipeItemAdapterMangerImpl mItemManger = new SwipeItemAdapterMangerImpl(this);
|
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
||||||
protected CursorSwipeAdapter(Context context, Cursor c, boolean autoRequery) {
|
protected CursorSwipeAdapter(Context context, Cursor c, boolean autoRequery) {
|
||||||
super(context, c, autoRequery);
|
super(context, c, autoRequery);
|
||||||
|
|
@ -29,13 +28,8 @@ public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
boolean convertViewIsNull = convertView == null;
|
|
||||||
View v = super.getView(position, convertView, parent);
|
View v = super.getView(position, convertView, parent);
|
||||||
if(convertViewIsNull){
|
mItemManger.bind(v, position);
|
||||||
mItemManger.initialize(v, position);
|
|
||||||
}else{
|
|
||||||
mItemManger.updateConvertView(v, position);
|
|
||||||
}
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,6 +48,11 @@ public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeI
|
||||||
mItemManger.closeAllExcept(layout);
|
mItemManger.closeAllExcept(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeAllItems() {
|
||||||
|
mItemManger.closeAllItems();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> getOpenItems() {
|
public List<Integer> getOpenItems() {
|
||||||
return mItemManger.getOpenItems();
|
return mItemManger.getOpenItems();
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemRecyclerMangerImpl;
|
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class RecyclerSwipeAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class RecyclerSwipeAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
public SwipeItemRecyclerMangerImpl mItemManger = new SwipeItemRecyclerMangerImpl(this);
|
public SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract VH onCreateViewHolder(ViewGroup parent, int viewType);
|
public abstract VH onCreateViewHolder(ViewGroup parent, int viewType);
|
||||||
|
|
@ -21,6 +21,11 @@ public abstract class RecyclerSwipeAdapter<VH extends RecyclerView.ViewHolder> e
|
||||||
@Override
|
@Override
|
||||||
public abstract void onBindViewHolder(VH viewHolder, final int position);
|
public abstract void onBindViewHolder(VH viewHolder, final int position);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDatasetChanged() {
|
||||||
|
super.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openItem(int position) {
|
public void openItem(int position) {
|
||||||
mItemManger.openItem(position);
|
mItemManger.openItem(position);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemAdapterMangerImpl;
|
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
|
|
@ -17,7 +16,7 @@ import java.util.List;
|
||||||
|
|
||||||
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
|
||||||
|
|
||||||
private SwipeItemAdapterMangerImpl mItemManger = new SwipeItemAdapterMangerImpl(this);
|
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
|
||||||
|
|
||||||
protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
|
||||||
super(context, layout, c, from, to, flags);
|
super(context, layout, c, from, to, flags);
|
||||||
|
|
@ -29,13 +28,8 @@ public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
boolean convertViewIsNull = convertView == null;
|
|
||||||
View v = super.getView(position, convertView, parent);
|
View v = super.getView(position, convertView, parent);
|
||||||
if(convertViewIsNull){
|
mItemManger.bind(v, position);
|
||||||
mItemManger.initialize(v, position);
|
|
||||||
}else{
|
|
||||||
mItemManger.updateConvertView(v, position);
|
|
||||||
}
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
package com.daimajia.swipe.implments;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
|
|
||||||
import com.daimajia.swipe.SimpleSwipeListener;
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
|
||||||
import com.daimajia.swipe.util.Attributes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SwipeItemMangerImpl is a helper class to help all the adapters to maintain open status.
|
|
||||||
*/
|
|
||||||
public class SwipeItemAdapterMangerImpl extends SwipeItemMangerImpl{
|
|
||||||
|
|
||||||
protected BaseAdapter mAdapter;
|
|
||||||
|
|
||||||
public SwipeItemAdapterMangerImpl(BaseAdapter adapter) {
|
|
||||||
super(adapter);
|
|
||||||
this.mAdapter = adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(View target, int position) {
|
|
||||||
int resId = getSwipeLayoutId(position);
|
|
||||||
|
|
||||||
OnLayoutListener onLayoutListener = new OnLayoutListener(position);
|
|
||||||
SwipeLayout swipeLayout = (SwipeLayout) target.findViewById(resId);
|
|
||||||
if (swipeLayout == null)
|
|
||||||
throw new IllegalStateException("can not find SwipeLayout in target view");
|
|
||||||
|
|
||||||
SwipeMemory swipeMemory = new SwipeMemory(position);
|
|
||||||
swipeLayout.addSwipeListener(swipeMemory);
|
|
||||||
swipeLayout.addOnLayoutListener(onLayoutListener);
|
|
||||||
swipeLayout.setTag(resId, new ValueBox(position, swipeMemory, onLayoutListener));
|
|
||||||
|
|
||||||
mShownLayouts.add(swipeLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateConvertView(View target, int position) {
|
|
||||||
int resId = getSwipeLayoutId(position);
|
|
||||||
|
|
||||||
SwipeLayout swipeLayout = (SwipeLayout) target.findViewById(resId);
|
|
||||||
if (swipeLayout == null)
|
|
||||||
throw new IllegalStateException("can not find SwipeLayout in target view");
|
|
||||||
|
|
||||||
ValueBox valueBox = (ValueBox) swipeLayout.getTag(resId);
|
|
||||||
valueBox.swipeMemory.setPosition(position);
|
|
||||||
valueBox.onLayoutListener.setPosition(position);
|
|
||||||
valueBox.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindView(View target, int position){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.daimajia.swipe.implments;
|
package com.daimajia.swipe.implments;
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
|
|
||||||
import com.daimajia.swipe.SimpleSwipeListener;
|
import com.daimajia.swipe.SimpleSwipeListener;
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
|
|
@ -11,7 +9,7 @@ import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -19,7 +17,7 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
* SwipeItemMangerImpl is a helper class to help all the adapters to maintain open status.
|
* SwipeItemMangerImpl is a helper class to help all the adapters to maintain open status.
|
||||||
*/
|
*/
|
||||||
public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
public class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
|
|
||||||
private Attributes.Mode mode = Attributes.Mode.Single;
|
private Attributes.Mode mode = Attributes.Mode.Single;
|
||||||
public final int INVALID_POSITION = -1;
|
public final int INVALID_POSITION = -1;
|
||||||
|
|
@ -29,27 +27,13 @@ public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
protected Set<Integer> mOpenPositions = new HashSet<Integer>();
|
protected Set<Integer> mOpenPositions = new HashSet<Integer>();
|
||||||
protected Set<SwipeLayout> mShownLayouts = new HashSet<SwipeLayout>();
|
protected Set<SwipeLayout> mShownLayouts = new HashSet<SwipeLayout>();
|
||||||
|
|
||||||
protected BaseAdapter mBaseAdapter;
|
protected SwipeAdapterInterface swipeAdapterInterface;
|
||||||
protected RecyclerView.Adapter mRecyclerAdapter;
|
|
||||||
|
|
||||||
public SwipeItemMangerImpl(BaseAdapter adapter) {
|
public SwipeItemMangerImpl(SwipeAdapterInterface swipeAdapterInterface) {
|
||||||
if (adapter == null)
|
if (swipeAdapterInterface == null)
|
||||||
throw new IllegalArgumentException("Adapter can not be null");
|
throw new IllegalArgumentException("SwipeAdapterInterface can not be null");
|
||||||
|
|
||||||
if (!(adapter instanceof SwipeItemMangerInterface))
|
this.swipeAdapterInterface = swipeAdapterInterface;
|
||||||
throw new IllegalArgumentException("adapter should implement the SwipeAdapterInterface");
|
|
||||||
|
|
||||||
this.mBaseAdapter = adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SwipeItemMangerImpl(RecyclerView.Adapter adapter) {
|
|
||||||
if (adapter == null)
|
|
||||||
throw new IllegalArgumentException("Adapter can not be null");
|
|
||||||
|
|
||||||
if (!(adapter instanceof SwipeItemMangerInterface))
|
|
||||||
throw new IllegalArgumentException("adapter should implement the SwipeAdapterInterface");
|
|
||||||
|
|
||||||
this.mRecyclerAdapter = adapter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attributes.Mode getMode() {
|
public Attributes.Mode getMode() {
|
||||||
|
|
@ -63,21 +47,24 @@ public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
mOpenPosition = INVALID_POSITION;
|
mOpenPosition = INVALID_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize and updateConvertView used for AdapterManagerImpl */
|
public void bind(View view, int position) {
|
||||||
public abstract void initialize(View target, int position);
|
int resId = swipeAdapterInterface.getSwipeLayoutResourceId(position);
|
||||||
|
SwipeLayout swipeLayout = (SwipeLayout) view.findViewById(resId);
|
||||||
|
if (swipeLayout == null)
|
||||||
|
throw new IllegalStateException("can not find SwipeLayout in target view");
|
||||||
|
|
||||||
public abstract void updateConvertView(View target, int position);
|
if (swipeLayout.getTag(resId) == null) {
|
||||||
|
OnLayoutListener onLayoutListener = new OnLayoutListener(position);
|
||||||
/* bindView used for RecyclerViewManagerImpl */
|
SwipeMemory swipeMemory = new SwipeMemory(position);
|
||||||
public abstract void bindView(View target, int position);
|
swipeLayout.addSwipeListener(swipeMemory);
|
||||||
|
swipeLayout.addOnLayoutListener(onLayoutListener);
|
||||||
public int getSwipeLayoutId(int position) {
|
swipeLayout.setTag(resId, new ValueBox(position, swipeMemory, onLayoutListener));
|
||||||
if (mBaseAdapter != null) {
|
mShownLayouts.add(swipeLayout);
|
||||||
return ((SwipeAdapterInterface) (mBaseAdapter)).getSwipeLayoutResourceId(position);
|
|
||||||
} else if (mRecyclerAdapter != null) {
|
|
||||||
return ((SwipeAdapterInterface) (mRecyclerAdapter)).getSwipeLayoutResourceId(position);
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
ValueBox valueBox = (ValueBox) swipeLayout.getTag(resId);
|
||||||
|
valueBox.swipeMemory.setPosition(position);
|
||||||
|
valueBox.onLayoutListener.setPosition(position);
|
||||||
|
valueBox.position = position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,11 +76,7 @@ public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
} else {
|
} else {
|
||||||
mOpenPosition = position;
|
mOpenPosition = position;
|
||||||
}
|
}
|
||||||
if (mBaseAdapter != null) {
|
swipeAdapterInterface.notifyDatasetChanged();
|
||||||
mBaseAdapter.notifyDataSetChanged();
|
|
||||||
} else if (mRecyclerAdapter != null) {
|
|
||||||
mRecyclerAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -104,11 +87,7 @@ public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
if (mOpenPosition == position)
|
if (mOpenPosition == position)
|
||||||
mOpenPosition = INVALID_POSITION;
|
mOpenPosition = INVALID_POSITION;
|
||||||
}
|
}
|
||||||
if (mBaseAdapter != null) {
|
swipeAdapterInterface.notifyDatasetChanged();
|
||||||
mBaseAdapter.notifyDataSetChanged();
|
|
||||||
} else if (mRecyclerAdapter != null) {
|
|
||||||
mRecyclerAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -141,7 +120,7 @@ public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
||||||
if (mode == Attributes.Mode.Multiple) {
|
if (mode == Attributes.Mode.Multiple) {
|
||||||
return new ArrayList<Integer>(mOpenPositions);
|
return new ArrayList<Integer>(mOpenPositions);
|
||||||
} else {
|
} else {
|
||||||
return Arrays.asList(mOpenPosition);
|
return Collections.singletonList(mOpenPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package com.daimajia.swipe.implments;
|
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.daimajia.swipe.SimpleSwipeListener;
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
|
||||||
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
|
||||||
import com.daimajia.swipe.util.Attributes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SwipeItemRecyclerMangerImpl is a helper class to help the RecyclerView to maintain open status.
|
|
||||||
*/
|
|
||||||
public class SwipeItemRecyclerMangerImpl extends SwipeItemMangerImpl{
|
|
||||||
|
|
||||||
protected RecyclerView.Adapter mAdapter;
|
|
||||||
|
|
||||||
public SwipeItemRecyclerMangerImpl(RecyclerView.Adapter adapter) {
|
|
||||||
super(adapter);
|
|
||||||
this.mAdapter = adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindView(View target, int position) {
|
|
||||||
int resId = getSwipeLayoutId(position);
|
|
||||||
|
|
||||||
OnLayoutListener onLayoutListener = new OnLayoutListener(position);
|
|
||||||
SwipeLayout swipeLayout = (SwipeLayout) target.findViewById(resId);
|
|
||||||
if (swipeLayout == null)
|
|
||||||
throw new IllegalStateException("can not find SwipeLayout in target view");
|
|
||||||
|
|
||||||
if (swipeLayout.getTag(resId) == null) {
|
|
||||||
SwipeMemory swipeMemory = new SwipeMemory(position);
|
|
||||||
swipeLayout.addSwipeListener(swipeMemory);
|
|
||||||
swipeLayout.addOnLayoutListener(onLayoutListener);
|
|
||||||
swipeLayout.setTag(resId, new ValueBox(position, swipeMemory, onLayoutListener));
|
|
||||||
mShownLayouts.add(swipeLayout);
|
|
||||||
} else {
|
|
||||||
ValueBox valueBox = (ValueBox) swipeLayout.getTag(resId);
|
|
||||||
valueBox.swipeMemory.setPosition(position);
|
|
||||||
valueBox.onLayoutListener.setPosition(position);
|
|
||||||
valueBox.position = position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(View target, int position) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateConvertView(View target, int position) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package com.daimajia.swipe.interfaces;
|
package com.daimajia.swipe.interfaces;
|
||||||
|
|
||||||
public interface SwipeAdapterInterface {
|
public interface SwipeAdapterInterface {
|
||||||
public int getSwipeLayoutResourceId(int position);
|
|
||||||
|
int getSwipeLayoutResourceId(int position);
|
||||||
|
|
||||||
|
void notifyDatasetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,29 @@
|
||||||
package com.daimajia.swipe.interfaces;
|
package com.daimajia.swipe.interfaces;
|
||||||
|
|
||||||
import com.daimajia.swipe.SwipeLayout;
|
import com.daimajia.swipe.SwipeLayout;
|
||||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
|
||||||
import com.daimajia.swipe.util.Attributes;
|
import com.daimajia.swipe.util.Attributes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SwipeItemMangerInterface {
|
public interface SwipeItemMangerInterface {
|
||||||
|
|
||||||
public void openItem(int position);
|
void openItem(int position);
|
||||||
|
|
||||||
public void closeItem(int position);
|
void closeItem(int position);
|
||||||
|
|
||||||
public void closeAllExcept(SwipeLayout layout);
|
void closeAllExcept(SwipeLayout layout);
|
||||||
|
|
||||||
public void closeAllItems();
|
void closeAllItems();
|
||||||
|
|
||||||
public List<Integer> getOpenItems();
|
List<Integer> getOpenItems();
|
||||||
|
|
||||||
public List<SwipeLayout> getOpenLayouts();
|
List<SwipeLayout> getOpenLayouts();
|
||||||
|
|
||||||
public void removeShownLayouts(SwipeLayout layout);
|
void removeShownLayouts(SwipeLayout layout);
|
||||||
|
|
||||||
public boolean isOpen(int position);
|
boolean isOpen(int position);
|
||||||
|
|
||||||
public Attributes.Mode getMode();
|
Attributes.Mode getMode();
|
||||||
|
|
||||||
public void setMode(Attributes.Mode mode);
|
void setMode(Attributes.Mode mode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@
|
||||||
<enum name="lay_down" value="0" />
|
<enum name="lay_down" value="0" />
|
||||||
<enum name="pull_out" value="1" />
|
<enum name="pull_out" value="1" />
|
||||||
</attr>
|
</attr>
|
||||||
|
<attr name="clickToClose" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue