Android Swipe Layout born
|
|
@ -0,0 +1,43 @@
|
|||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
.DS_Store
|
||||
/build
|
||||
# built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# files for the dex VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
.DS_Store
|
||||
|
||||
# generated files
|
||||
bin/
|
||||
gen/
|
||||
Wiki/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
#Android Studio
|
||||
build/
|
||||
|
||||
# Intellij project files
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
#gradle
|
||||
.gradle/
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
# Android Swipe Layout
|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
I found it's pretty hard to archive this effect, cause you have to be very familiar with the Android Touch System. It was beyond my ability that moment, and I also noticed that there was no such a concept library...
|
||||
|
||||
So... as you see right now.
|
||||
|
||||
## Demo
|
||||
|
||||

|
||||
|
||||
Before I made this, I actually found some libraries (eg.[SwipeListView](https://github.com/47deg/android-swipelistview)) that helps developers to integrate swiping with your UI component. But they have too much limitation, only in ListView, or some other limitations.
|
||||
|
||||
When I start to make this library, I set some goals:
|
||||
|
||||
- Can be easily integrated in anywhere, ListView, GridView, ViewGroup etc.
|
||||
- Can receive `onOpen`,`onClose`,`onUpdate` callbacks.
|
||||
- Can notifiy the hidden children how much they have shown.
|
||||
- Can be nested each other.
|
||||
|
||||
## Usage
|
||||
|
||||
### Step 1
|
||||
#### Gradle
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
compile "com.daimajia.swipelayout:library:1.0.0@aar"
|
||||
}
|
||||
```
|
||||
|
||||
#### Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.daimajia.swipelayout</groupId>
|
||||
<artifactId>library</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<type>apklib</type>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
#### Eclipse
|
||||
|
||||
|
||||
### Step 2
|
||||
|
||||
Create a `SwipeLayout`:
|
||||
|
||||
- `SwipeLayout` must have 2 children (all should be an instance of `ViewGroup`).
|
||||
|
||||
```xml
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="80dp">
|
||||
<!-- Bottom View Start-->
|
||||
<LinearLayout
|
||||
android:background="#66ddff00"
|
||||
android:id="@+id/bottom_wrapper"
|
||||
android:layout_width="160dp"
|
||||
android:weightSum="1"
|
||||
android:layout_height="match_parent">
|
||||
<!--What you want to show-->
|
||||
</LinearLayout>
|
||||
<!-- Bottom View End-->
|
||||
|
||||
<!-- Surface View Start -->
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!--What you want to show in SurfaceView-->
|
||||
</LinearLayout>
|
||||
<!-- Surface View End -->
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
```
|
||||
|
||||
There are some preset examples: [example1](./demo/src/main/res/layout/sample1.xml), [example2](./demo/src/main/res/layout/sample2.xml), [example3](./demo/src/main/res/layout/sample3.xml).
|
||||
|
||||
### Step3
|
||||
|
||||
[Source code](./demo/src/main/java/com/daimajia/swipedemo/MyActivity.java).
|
||||
|
||||
## Wiki
|
||||
|
||||
Wiki is under construction.
|
||||
|
||||
## About me
|
||||
|
||||
A student in mainland China.
|
||||
|
||||
Welcome to [offer me an internship](mailto:daimajia@gmail.com). If you have any new idea about this project, feel free to [contact me](mailto:daimajia@gmail.com). :smiley:
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.12.+'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 18
|
||||
buildToolsVersion "20.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.daimajia.swipedemo"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 18
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile project(":library")
|
||||
compile 'com.nineoldandroids:library:2.4.0'
|
||||
compile 'com.daimajia.easing:library:1.0.0@aar'
|
||||
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.daimajia.swipe;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.daimajia.swipedemo" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.daimajia.swipedemo.MyActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.daimajia.swipedemo.ListViewExample"/>
|
||||
<activity android:name="com.daimajia.swipedemo.GridViewExample"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.daimajia.swipedemo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import com.daimajia.swipedemo.adapter.GridViewAdapter;
|
||||
|
||||
public class GridViewExample extends Activity{
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.gridview);
|
||||
final GridView gridView = (GridView)findViewById(R.id.gridview);
|
||||
gridView.setAdapter(new GridViewAdapter(this));
|
||||
gridView.setSelected(false);
|
||||
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("onItemLongClick","onItemLongClick:" + position);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("onItemClick","onItemClick:" + position);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
gridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("onItemSelected","onItemSelected:" + position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package com.daimajia.swipedemo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.daimajia.swipedemo.adapter.ListViewAdapter;
|
||||
|
||||
public class ListViewExample extends Activity {
|
||||
|
||||
private ListView mListView;
|
||||
private ListViewAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.listview);
|
||||
mListView = (ListView)findViewById(R.id.listview);
|
||||
mAdapter = new ListViewAdapter(this);
|
||||
mListView.setAdapter(mAdapter);
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("ListView", "onItemClick:" + position);
|
||||
}
|
||||
});
|
||||
mListView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
Log.e("ListView","OnTouch");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("ListView","onItemLongClick:" + position);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
Log.e("ListView","onScrollStateChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("ListView", "onItemSelected:" + position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
Log.e("ListView", "onNothingSelected:");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.my, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_listview) {
|
||||
startActivity(new Intent(this, ListViewExample.class));
|
||||
return true;
|
||||
}else if(id == R.id.action_gridview){
|
||||
startActivity(new Intent(this, GridViewExample.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.daimajia.swipedemo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
|
||||
public class MyActivity extends Activity {
|
||||
|
||||
private SwipeLayout sample1, sample2,sample3;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.godfather);
|
||||
swipeLayout.setDragEdge(SwipeLayout.DragEdge.Bottom);
|
||||
|
||||
//
|
||||
sample1 = (SwipeLayout)findViewById(R.id.sample1);
|
||||
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
sample1.setDragEdge(SwipeLayout.DragEdge.Left);
|
||||
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
|
||||
@Override
|
||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sample2 = (SwipeLayout)findViewById(R.id.sample2);
|
||||
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||
sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample2.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
sample2.findViewById(R.id.magnifier).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
// sample2.addRevealListener(new int[]{R.id.magnifier, R.id.star, R.id.trash}, new SwipeLayout.OnRevealListener() {
|
||||
// @Override
|
||||
// public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||
// child.setScaleX(fraction);
|
||||
// }
|
||||
// });
|
||||
|
||||
sample2.findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Yo",Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
sample3 = (SwipeLayout)findViewById(R.id.sample3);
|
||||
sample3.setDragEdge(SwipeLayout.DragEdge.Top);
|
||||
sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {
|
||||
@Override
|
||||
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
|
||||
View star = child.findViewById(R.id.star);
|
||||
float d = child.getHeight() / 2 - star.getHeight() / 2;
|
||||
star.setTranslationY(d * fraction);
|
||||
star.setScaleX(fraction+0.6f);
|
||||
star.setScaleY(fraction+0.6f);
|
||||
int c = (Integer)evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B"));
|
||||
child.setBackgroundColor(c);
|
||||
}
|
||||
});
|
||||
sample3.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
// final int[] res = new int[]{R.id.changeLeft, R.id.changeRight, R.id.changeTop, R.id.changeBottom};
|
||||
// final SwipeLayout.DragEdge[] edges = new SwipeLayout.DragEdge[]{SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top, SwipeLayout.DragEdge.Bottom};
|
||||
// final SwipeLayout[] layouts = new SwipeLayout[]{sample1,sample2,sample3};
|
||||
// for(int i = 0; i < res.length; i++){
|
||||
// findViewById(res[i]).setTag(edges[i]);
|
||||
// findViewById(res[i]).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// for (SwipeLayout l : layouts) {
|
||||
// l.setDragEdge((SwipeLayout.DragEdge) v.getTag());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// findViewById(R.id.pullout).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// for (SwipeLayout l : layouts) {
|
||||
// l.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// findViewById(R.id.laydown).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// for(SwipeLayout l : layouts){
|
||||
// l.setShowMode(SwipeLayout.ShowMode.LayDown);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.my, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_listview) {
|
||||
startActivity(new Intent(this, ListViewExample.class));
|
||||
return true;
|
||||
}else if(id == R.id.action_gridview){
|
||||
startActivity(new Intent(this, GridViewExample.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public Object evaluate(float fraction, Object startValue, Object endValue) {
|
||||
int startInt = (Integer) startValue;
|
||||
int startA = (startInt >> 24) & 0xff;
|
||||
int startR = (startInt >> 16) & 0xff;
|
||||
int startG = (startInt >> 8) & 0xff;
|
||||
int startB = startInt & 0xff;
|
||||
|
||||
int endInt = (Integer) endValue;
|
||||
int endA = (endInt >> 24) & 0xff;
|
||||
int endR = (endInt >> 16) & 0xff;
|
||||
int endG = (endInt >> 8) & 0xff;
|
||||
int endB = endInt & 0xff;
|
||||
|
||||
return (int)((startA + (int)(fraction * (endA - startA))) << 24) |
|
||||
(int)((startR + (int)(fraction * (endR - startR))) << 16) |
|
||||
(int)((startG + (int)(fraction * (endG - startG))) << 8) |
|
||||
(int)((startB + (int)(fraction * (endB - startB))));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.daimajia.swipedemo.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipedemo.R;
|
||||
|
||||
public class GridViewAdapter extends SwipeAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public GridViewAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSwipeLayoutResourceId(int position) {
|
||||
return R.id.swipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View generateView(int position, ViewGroup parent) {
|
||||
return LayoutInflater.from(mContext).inflate(R.layout.grid_item, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillValues(int position, View convertView) {
|
||||
TextView t = (TextView)convertView.findViewById(R.id.position);
|
||||
t.setText((position + 1 )+".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package com.daimajia.swipedemo.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.daimajia.androidanimations.library.Techniques;
|
||||
import com.daimajia.androidanimations.library.YoYo;
|
||||
import com.daimajia.swipe.SwipeAdapter;
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
import com.daimajia.swipedemo.R;
|
||||
|
||||
public class ListViewAdapter extends SwipeAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public ListViewAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSwipeLayoutResourceId(int position) {
|
||||
return R.id.swipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View generateView(int position, ViewGroup parent) {
|
||||
View v = LayoutInflater.from(mContext).inflate(R.layout.listview_item, null);
|
||||
SwipeLayout swipeLayout = (SwipeLayout)v.findViewById(getSwipeLayoutResourceId(position));
|
||||
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
|
||||
@Override
|
||||
public void onClose(SwipeLayout layout) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(SwipeLayout layout) {
|
||||
YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
|
||||
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillValues(int position, View convertView) {
|
||||
TextView t = (TextView)convertView.findViewById(R.id.position);
|
||||
t.setText((position + 1) + ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/hover_border_pressed" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/hover_border_pressed" android:state_focused="true"/>
|
||||
<item android:drawable="@drawable/hover_border_normal"/>
|
||||
|
||||
</selector>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:innerRadius="10dp" >
|
||||
|
||||
<stroke
|
||||
android:width="10dp"
|
||||
android:color="#f3f300" />
|
||||
|
||||
<solid android:color="#f9f9f9" />
|
||||
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#e2e2e2" />
|
||||
|
||||
<solid android:color="#f9f9f9" />
|
||||
|
||||
<gradient
|
||||
android:endColor="#66E8E8E8"
|
||||
android:gradientRadius="150"
|
||||
android:startColor="#ffffffff"
|
||||
android:type="radial" />
|
||||
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/swipe"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:tag="Bottom2"
|
||||
android:background="#333"
|
||||
android:layout_width="40dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="120dp">
|
||||
<ImageView
|
||||
android:id="@+id/trash"
|
||||
android:src="@drawable/trash"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:tag="Hover"
|
||||
android:text="If winter comes , can spring be far behind ? \n"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/gridview"
|
||||
android:padding="10dp"
|
||||
android:verticalSpacing="10dp"
|
||||
android:horizontalSpacing="10dp"
|
||||
android:numColumns="2"
|
||||
android:listSelector="@drawable/hover_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ListView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/listview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
android:id="@+id/swipe"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="800dp"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:background="#FF5534"
|
||||
android:tag="Bottom3"
|
||||
android:weightSum="10"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp">
|
||||
<ImageView
|
||||
android:id="@+id/trash"
|
||||
android:src="@drawable/trash"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="27dp"
|
||||
android:layout_height="30dp" />
|
||||
<TextView
|
||||
android:text="Delete Item?"
|
||||
android:textSize="17sp"
|
||||
android:textColor="#fff"
|
||||
android:layout_weight="5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/delete"
|
||||
android:textColor="#FF5534"
|
||||
android:background="#ffffff"
|
||||
android:text="Yes,Delete"
|
||||
android:layout_weight="4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:padding="10dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:tag="Hover"
|
||||
android:text="Do not, for one repulse, forgo the purpose that you resolved to effort. "
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/godfather"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:src="@drawable/bird"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<include layout="@layout/sample_together" android:layout_width="match_parent" android:layout_height="match_parent"/>
|
||||
<ImageView
|
||||
android:src="@drawable/hand"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp" />
|
||||
</RelativeLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?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="Bottom1"
|
||||
android:background="#66ddff00"
|
||||
android:id="@+id/bottom_wrapper"
|
||||
android:layout_width="160dp"
|
||||
android:weightSum="1"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/archive"
|
||||
android:textColor="#fff"
|
||||
android:text="Archive"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center"
|
||||
android:background="#FF1300"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" />
|
||||
<TextView
|
||||
android:id="@+id/delete"
|
||||
android:text="Delete"
|
||||
android:background="#C7C7CC"
|
||||
android:gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" />
|
||||
</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>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?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="match_parent">
|
||||
<LinearLayout
|
||||
android:tag="Bottom2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/magnifier"
|
||||
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/star"
|
||||
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/trash"
|
||||
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:padding="10dp"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:tag="Hover"
|
||||
android:text="理解(りかい)されるということは、一種(いっしゅ)の贅沢(ぜいたく)である。"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:visibility="invisible"
|
||||
android:id="@+id/click"
|
||||
android:text="Click"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?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="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:tag="Bottom3"
|
||||
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="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>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp"
|
||||
tools:context=".MyActivity">
|
||||
|
||||
<include android:id="@+id/sample1" layout="@layout/sample1"
|
||||
android:layout_width="match_parent" android:layout_height="80dp"/>
|
||||
|
||||
|
||||
<include android:id="@+id/sample2" layout="@layout/sample2"
|
||||
android:layout_width="match_parent" android:layout_height="80dp"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
<include android:id="@+id/sample3" layout="@layout/sample3"
|
||||
android:layout_width="match_parent" android:layout_height="80dp"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="invisible"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:weightSum="4"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:id="@+id/changeLeft"
|
||||
android:text="Left"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/changeRight"
|
||||
android:text="Right"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/changeTop"
|
||||
android:text="Top"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/changeBottom"
|
||||
android:text="Bottom"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="invisible"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:weightSum="2"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:id="@+id/pullout"
|
||||
android:text="PullOut"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/laydown"
|
||||
android:text="LayDown"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".MyActivity" >
|
||||
<item android:id="@+id/action_listview"
|
||||
android:title="ListView"
|
||||
android:orderInCategory="100"
|
||||
/>
|
||||
<item android:id="@+id/action_gridview"
|
||||
android:title="GridView"
|
||||
android:orderInCategory="100"
|
||||
/>
|
||||
</menu>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">AndroidSwipeLayout</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Settings specified in this file will override any Gradle settings
|
||||
# configured through the IDE.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
|
||||
VERSION_NAME=1.0.0
|
||||
VERSION_CODE=1
|
||||
GROUP=com.daimajia.swipelayout
|
||||
|
||||
POM_DESCRIPTION=Android Swipe Layout
|
||||
POM_URL=https://github.com/daimajia/AndroidSwipeLayout
|
||||
POM_SCM_URL=https://github.com/daimajia/AndroidSwipeLayout
|
||||
POM_SCM_CONNECTION=scm:https://github.com/daimajia/AndroidSwipeLayout.git
|
||||
POM_SCM_DEV_CONNECTION=scm:https://github.com/daimajia/AndroidSwipeLayout.git
|
||||
POM_LICENCE_NAME=MIT
|
||||
POM_LICENCE_URL=http://opensource.org/licenses/MIT
|
||||
POM_LICENCE_DIST=repo
|
||||
POM_DEVELOPER_ID=daimajia
|
||||
POM_DEVELOPER_NAME=daimajia
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 20
|
||||
buildToolsVersion "20.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.daimajia.swipelayout"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
runProguard false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:19.+'
|
||||
}
|
||||
apply from: './gradle-mvn-push.gradle'
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright 2013 Chris Banes
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'signing'
|
||||
|
||||
def isReleaseBuild() {
|
||||
return VERSION_NAME.contains("SNAPSHOT") == false
|
||||
}
|
||||
|
||||
def getReleaseRepositoryUrl() {
|
||||
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
||||
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
}
|
||||
|
||||
def getSnapshotRepositoryUrl() {
|
||||
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
||||
: "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
|
||||
def getRepositoryUsername() {
|
||||
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
|
||||
}
|
||||
|
||||
def getRepositoryPassword() {
|
||||
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
|
||||
}
|
||||
|
||||
afterEvaluate { project ->
|
||||
uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||
|
||||
pom.groupId = GROUP
|
||||
pom.artifactId = POM_ARTIFACT_ID
|
||||
pom.version = VERSION_NAME
|
||||
|
||||
repository(url: getReleaseRepositoryUrl()) {
|
||||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
|
||||
}
|
||||
snapshotRepository(url: getSnapshotRepositoryUrl()) {
|
||||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
|
||||
}
|
||||
|
||||
pom.project {
|
||||
name POM_NAME
|
||||
packaging POM_PACKAGING
|
||||
description POM_DESCRIPTION
|
||||
url POM_URL
|
||||
|
||||
scm {
|
||||
url POM_SCM_URL
|
||||
connection POM_SCM_CONNECTION
|
||||
developerConnection POM_SCM_DEV_CONNECTION
|
||||
}
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name POM_LICENCE_NAME
|
||||
url POM_LICENCE_URL
|
||||
distribution POM_LICENCE_DIST
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id POM_DEVELOPER_ID
|
||||
name POM_DEVELOPER_NAME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
|
||||
sign configurations.archives
|
||||
}
|
||||
|
||||
task apklib(type: Zip){
|
||||
appendix = extension = 'apklib'
|
||||
|
||||
from 'AndroidManifest.xml'
|
||||
into('res') {
|
||||
from 'res'
|
||||
}
|
||||
into('src') {
|
||||
from 'src'
|
||||
}
|
||||
}
|
||||
|
||||
task jar(type: Jar) {
|
||||
from android.sourceSets.main.java
|
||||
}
|
||||
|
||||
task androidJavadocs(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.srcDirs
|
||||
classpath += project.files(android.getBootClasspath() .join(File.pathSeparator))
|
||||
}
|
||||
|
||||
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
||||
classifier = 'javadoc'
|
||||
from androidJavadocs.destinationDir
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives androidSourcesJar
|
||||
archives androidJavadocsJar
|
||||
archives apklib
|
||||
archives jar
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Settings specified in this file will override any Gradle settings
|
||||
# configured through the IDE.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
POM_NAME=Android SwipeLayout Library
|
||||
POM_ARTIFACT_ID=library
|
||||
POM_PACKAGING=aar
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.daimajia.swipe;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.daimajia.swipe">
|
||||
|
||||
<application android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package com.daimajia.swipe;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class SwipeAdapter extends BaseAdapter {
|
||||
|
||||
private Set<Integer> mOpenPositions = new HashSet<Integer>();
|
||||
|
||||
/**
|
||||
* return the {@link com.daimajia.swipe.SwipeLayout} resource id, int the view item.
|
||||
* @param position
|
||||
* @return
|
||||
*/
|
||||
public abstract int getSwipeLayoutResourceId(int position);
|
||||
|
||||
/**
|
||||
* generate a new view item, you don't need to fill any value to this view, you have a chance
|
||||
* to fill it in {@code fillValues} method.
|
||||
* @param position
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
public abstract View generateView(int position, ViewGroup parent);
|
||||
|
||||
/**
|
||||
* fill values to the view.
|
||||
* @param position
|
||||
* @param convertView
|
||||
*/
|
||||
public abstract void fillValues(int position, View convertView);
|
||||
|
||||
|
||||
@Override
|
||||
public final View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
SwipeLayout swipeLayout;
|
||||
int swipeResourceId = getSwipeLayoutResourceId(position);
|
||||
if(v == null){
|
||||
v = generateView(position, parent);
|
||||
swipeLayout = (SwipeLayout)v.findViewById(swipeResourceId);
|
||||
if(swipeLayout != null){
|
||||
OnLayoutListener onLayoutListener = new OnLayoutListener(position);
|
||||
SwipeMemory swipeMemory = new SwipeMemory(position);
|
||||
swipeLayout.addSwipeListener(swipeMemory);
|
||||
swipeLayout.setTag(swipeResourceId, new ValueBox(position, swipeMemory, onLayoutListener));
|
||||
}
|
||||
}else{
|
||||
swipeLayout = (SwipeLayout)v.findViewById(swipeResourceId);
|
||||
if(swipeLayout != null){
|
||||
ValueBox valueBox = (ValueBox)swipeLayout.getTag(swipeResourceId);
|
||||
valueBox.swipeMemory.setPosition(position);
|
||||
valueBox.onLayoutListener.setPosition(position);
|
||||
valueBox.position = position;
|
||||
}
|
||||
}
|
||||
swipeLayout.addOnLayoutListener(new OnLayoutListener(position));
|
||||
fillValues(position, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
class ValueBox {
|
||||
OnLayoutListener onLayoutListener;
|
||||
SwipeMemory swipeMemory;
|
||||
int position;
|
||||
|
||||
ValueBox(int position, SwipeMemory swipeMemory, OnLayoutListener onLayoutListener) {
|
||||
this.swipeMemory = swipeMemory;
|
||||
this.onLayoutListener = onLayoutListener;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
class OnLayoutListener implements SwipeLayout.OnLayout{
|
||||
|
||||
private int position;
|
||||
|
||||
OnLayoutListener(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setPosition(int position){
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayout(SwipeLayout v) {
|
||||
v.removeOnLayoutListener(this);
|
||||
if(mOpenPositions.contains(position))
|
||||
v.open(false);
|
||||
else{
|
||||
v.close(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SwipeMemory implements SwipeLayout.SwipeListener {
|
||||
|
||||
private int position;
|
||||
|
||||
SwipeMemory(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(SwipeLayout layout) {
|
||||
mOpenPositions.remove(position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(SwipeLayout layout) {
|
||||
mOpenPositions.add(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
|
||||
|
||||
}
|
||||
|
||||
public void setPosition(int position){
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">library</string>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1 @@
|
|||
include ':demo', ':library'
|
||||