Repository: daimajia/AndroidSwipeLayout
Branch: master
Commit: 5f8678b04751
Files: 71
Total size: 164.7 KB
Directory structure:
gitextract_y9qg2upq/
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle
├── demo/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── daimajia/
│ │ └── swipedemo/
│ │ ├── GridViewExample.java
│ │ ├── ListViewExample.java
│ │ ├── MyActivity.java
│ │ ├── NestedExample.java
│ │ ├── RecyclerViewExample.java
│ │ └── adapter/
│ │ ├── ArraySwipeAdapterSample.java
│ │ ├── GridViewAdapter.java
│ │ ├── ListViewAdapter.java
│ │ ├── RecyclerViewAdapter.java
│ │ └── util/
│ │ ├── DividerItemDecoration.java
│ │ └── RecyclerItemClickListener.java
│ └── res/
│ ├── drawable/
│ │ ├── dark_gray.xml
│ │ ├── divider.xml
│ │ ├── item_selector.xml
│ │ ├── red.xml
│ │ └── white.xml
│ ├── layout/
│ │ ├── complicate_layout.xml
│ │ ├── grid_item.xml
│ │ ├── gridview.xml
│ │ ├── listview.xml
│ │ ├── listview_item.xml
│ │ ├── main.xml
│ │ ├── recyclerview.xml
│ │ ├── recyclerview_item.xml
│ │ ├── sampe_nested_edittext.xml
│ │ ├── sampe_nested_scrollview.xml
│ │ ├── sampe_nested_seekbar.xml
│ │ ├── sample1.xml
│ │ ├── sample2.xml
│ │ ├── sample3.xml
│ │ ├── sample_nested_parent.xml
│ │ └── sample_together.xml
│ ├── menu/
│ │ └── my.xml
│ ├── values/
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── values-w820dp/
│ └── dimens.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle-mvn-push.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── daimajia/
│ │ └── swipe/
│ │ ├── SimpleSwipeListener.java
│ │ ├── SwipeLayout.java
│ │ ├── adapters/
│ │ │ ├── ArraySwipeAdapter.java
│ │ │ ├── BaseSwipeAdapter.java
│ │ │ ├── CursorSwipeAdapter.java
│ │ │ ├── RecyclerSwipeAdapter.java
│ │ │ └── SimpleCursorSwipeAdapter.java
│ │ ├── implments/
│ │ │ └── SwipeItemMangerImpl.java
│ │ ├── interfaces/
│ │ │ ├── SwipeAdapterInterface.java
│ │ │ └── SwipeItemMangerInterface.java
│ │ └── util/
│ │ └── Attributes.java
│ └── res/
│ └── values/
│ └── attrs.xml
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.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/
================================================
FILE: .travis.yml
================================================
language: android
android:
components:
- tools
- platform-tools
- build-tools-25.0.2
- android-25
- extra-android-support
- extra
- extra-android-m2repository
script:
- ./gradlew assembleDebug
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 代码家
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# 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://insight.io/github.com/daimajia/AndroidSwipeLayout)
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 was pretty hard to achieve this effect, cause you had 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...
Time passed, finally...as you see right now.
## Demo

[Download Demo](https://github.com/daimajia/AndroidSwipeLayout/releases/download/v1.1.8/AndroidSwipeLayout-v1.1.8.apk)
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 it only works in `ListView`, and it has too many issues that they never care. What a pity!
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.
- Can handle complicate situation, just like [this](https://camo.githubusercontent.com/d145d9a9508b3d204b70882c05bc3d9bd433883c/687474703a2f2f7777312e73696e61696d672e636e2f6c617267652f3631306463303334677731656b686f6a7379326172673230386530366e6774312e676966).
## Usage
### Step 1
#### Gradle
```groovy
dependencies {
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:support-v4:20.+'
compile "com.daimajia.swipelayout:library:1.2.0@aar"
}
```
#### Maven
```xml
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>recyclerview-v7</artifactId>
<version>21.0.0</version>
</dependency>
<dependency>
<groupId>com.daimajia.swipelayout</groupId>
<artifactId>library</artifactId>
<version>1.2.0</version>
<type>apklib</type>
</dependency>
```
#### Eclipse
[AndroidSwipeLayout-v1.1.8.jar](https://github.com/daimajia/AndroidSwipeLayout/releases/download/v1.1.8/AndroidSwipeLayout-v1.1.8.jar)
### Step 2
**Make sure to use the internal adapter instead of your own!**
[Wiki Usage](https://github.com/daimajia/AndroidSwipeLayout/wiki/usage)
## Wiki
[Go to Wiki](https://github.com/daimajia/AndroidSwipeLayout/wiki)
## 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:
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
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
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
================================================
FILE: demo/.gitignore
================================================
/build
================================================
FILE: demo/build.gradle
================================================
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile project(":library")
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.daimajia.easing:library:1.0.0@aar'
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
compile 'com.nineoldandroids:library:2.4.0'
// This dude gave a shoutout to you (daimajia) on his github page:
compile 'jp.wasabeef:recyclerview-animators:1.0.3@aar'
}
================================================
FILE: demo/proguard-rules.pro
================================================
# 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 *;
#}
================================================
FILE: demo/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.daimajia.swipedemo">
<uses-sdk tools:overrideLibrary="org.lucasr.twowayview, org.lucasr.twowayview.widget, jp.wasabeef.recyclerview" />
<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" />
<activity android:name="com.daimajia.swipedemo.RecyclerViewExample" />
<activity android:name=".NestedExample" />
</application>
</manifest>
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/GridViewExample.java
================================================
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.swipe.util.Attributes;
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);
final GridViewAdapter adapter = new GridViewAdapter(this);
adapter.setMode(Attributes.Mode.Multiple);
gridView.setAdapter(adapter);
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) {
}
});
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/ListViewExample.java
================================================
package com.daimajia.swipedemo;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
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 android.widget.Toast;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.util.Attributes;
import com.daimajia.swipedemo.adapter.ListViewAdapter;
public class ListViewExample extends Activity {
private ListView mListView;
private ListViewAdapter mAdapter;
private Context mContext = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
mListView = (ListView) findViewById(R.id.listview);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle("ListView");
}
}
/**
* The following comment is the sample usage of ArraySwipeAdapter.
*/
// String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
// "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
// mListView.setAdapter(new ArraySwipeAdapterSample<String>(this, R.layout.listview_item, R.id.position, adapterData));
mAdapter = new ListViewAdapter(this);
mListView.setAdapter(mAdapter);
mAdapter.setMode(Attributes.Mode.Single);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
((SwipeLayout)(mListView.getChildAt(position - mListView.getFirstVisiblePosition()))).open(true);
}
});
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) {
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
return true;
}
});
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));
finish();
return true;
} else if (id == R.id.action_gridview) {
startActivity(new Intent(this, GridViewExample.class));
finish();
return true;
} else if (id == R.id.action_recycler) {
startActivity(new Intent(this, RecyclerViewExample.class));
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/MyActivity.java
================================================
package com.daimajia.swipedemo;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.daimajia.swipe.SwipeLayout;
import com.nineoldandroids.view.ViewHelper;
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); // Set in XML
//sample1
sample1 = (SwipeLayout) findViewById(R.id.sample1);
sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
View starBottView = sample1.findViewById(R.id.starbott);
sample1.addDrag(SwipeLayout.DragEdge.Left, sample1.findViewById(R.id.bottom_wrapper));
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() {
@Override
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
}
});
sample1.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "click on surface");
}
});
sample1.getSurfaceView().setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(MyActivity.this, "longClick on surface", Toast.LENGTH_SHORT).show();
Log.d(MyActivity.class.getName(), "longClick on surface");
return true;
}
});
sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
}
});
sample1.findViewById(R.id.trash2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
}
});
sample1.findViewById(R.id.magnifier2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
}
});
sample1.addRevealListener(R.id.starbott, 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;
ViewHelper.setTranslationY(star, d * fraction);
ViewHelper.setScaleX(star, fraction + 0.6f);
ViewHelper.setScaleY(star, fraction + 0.6f);
}
});
//sample2
sample2 = (SwipeLayout) findViewById(R.id.sample2);
sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
sample2.addDrag(SwipeLayout.DragEdge.Right, sample2.findViewWithTag("Bottom2"));
// 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.findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
}
});
sample2.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});
//sample3
sample3 = (SwipeLayout) findViewById(R.id.sample3);
sample3.addDrag(SwipeLayout.DragEdge.Top, sample3.findViewWithTag("Bottom3"));
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;
ViewHelper.setTranslationY(star, d * fraction);
ViewHelper.setScaleX(star, fraction + 0.6f);
ViewHelper.setScaleY(star, fraction + 0.6f);
int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B"));
child.setBackgroundColor(c);
}
});
sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
}
});
sample3.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
}
});
}
@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;
} else if (id == R.id.action_nested) {
startActivity(new Intent(this, NestedExample.class));
return true;
} else if (id == R.id.action_recycler) {
startActivity(new Intent(this, RecyclerViewExample.class));
}
return super.onOptionsItemSelected(item);
}
/*
Color transition method.
*/
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))));
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/NestedExample.java
================================================
package com.daimajia.swipedemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.daimajia.swipe.SwipeLayout;
public class NestedExample extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.complicate_layout);
SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.test_swipe_swipe);
swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {
@Override
public void onDoubleClick(SwipeLayout layout, boolean surface) {
Toast.makeText(getApplicationContext(), "DoubleClick", Toast.LENGTH_SHORT).show();
}
});
swipeLayout.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Click", Toast.LENGTH_SHORT).show();
}
});
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java
================================================
package com.daimajia.swipedemo;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.daimajia.swipe.util.Attributes;
import com.daimajia.swipedemo.adapter.RecyclerViewAdapter;
import com.daimajia.swipedemo.adapter.util.DividerItemDecoration;
import java.util.ArrayList;
import java.util.Arrays;
import jp.wasabeef.recyclerview.animators.FadeInLeftAnimator;
public class RecyclerViewExample extends Activity {
/**
* RecyclerView: The new recycler view replaces the list view. Its more modular and therefore we
* must implement some of the functionality ourselves and attach it to our recyclerview.
* <p/>
* 1) Position items on the screen: This is done with LayoutManagers
* 2) Animate & Decorate views: This is done with ItemAnimators & ItemDecorators
* 3) Handle any touch events apart from scrolling: This is now done in our adapter's ViewHolder
*/
private RecyclerView recyclerView;
private RecyclerView.Adapter mAdapter;
private ArrayList<String> mDataSet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recyclerview);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle("RecyclerView");
}
}
// Layout Managers:
recyclerView.setLayoutManager(new LinearLayoutManager(this));
// Item Decorator:
recyclerView.addItemDecoration(new DividerItemDecoration(getResources().getDrawable(R.drawable.divider)));
recyclerView.setItemAnimator(new FadeInLeftAnimator());
// Adapter:
String[] adapterData = new String[]{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
mAdapter = new RecyclerViewAdapter(this, mDataSet);
((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
recyclerView.setAdapter(mAdapter);
/* Listeners */
recyclerView.setOnScrollListener(onScrollListener);
}
/**
* Substitute for our onScrollListener for RecyclerView
*/
RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
Log.e("ListView", "onScrollStateChanged");
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// Could hide open views here if you wanted. //
}
};
@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));
finish();
return true;
} else if (id == R.id.action_gridview) {
startActivity(new Intent(this, GridViewExample.class));
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/ArraySwipeAdapterSample.java
================================================
package com.daimajia.swipedemo.adapter;
import android.content.Context;
import com.daimajia.swipe.adapters.ArraySwipeAdapter;
import com.daimajia.swipedemo.R;
import java.util.List;
/**
* Sample usage of ArraySwipeAdapter.
* @param <T>
*/
public class ArraySwipeAdapterSample<T> extends ArraySwipeAdapter {
public ArraySwipeAdapterSample(Context context, int resource) {
super(context, resource);
}
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
}
public ArraySwipeAdapterSample(Context context, int resource, Object[] objects) {
super(context, resource, objects);
}
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId, Object[] objects) {
super(context, resource, textViewResourceId, objects);
}
public ArraySwipeAdapterSample(Context context, int resource, List objects) {
super(context, resource, objects);
}
public ArraySwipeAdapterSample(Context context, int resource, int textViewResourceId, List objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public int getSwipeLayoutResourceId(int position) {
return R.id.swipe;
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/GridViewAdapter.java
================================================
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.adapters.BaseSwipeAdapter;
import com.daimajia.swipedemo.R;
public class GridViewAdapter extends BaseSwipeAdapter {
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;
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/ListViewAdapter.java
================================================
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 android.widget.Toast;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.daimajia.swipe.SimpleSwipeListener;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.adapters.BaseSwipeAdapter;
import com.daimajia.swipedemo.R;
public class ListViewAdapter extends BaseSwipeAdapter {
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 SimpleSwipeListener() {
@Override
public void onOpen(SwipeLayout layout) {
YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
}
});
swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {
@Override
public void onDoubleClick(SwipeLayout layout, boolean surface) {
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
}
});
v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "click delete", Toast.LENGTH_SHORT).show();
}
});
return v;
}
@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;
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java
================================================
package com.daimajia.swipedemo.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.daimajia.swipe.SimpleSwipeListener;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.adapters.RecyclerSwipeAdapter;
import com.daimajia.swipedemo.R;
import java.util.ArrayList;
public class RecyclerViewAdapter extends RecyclerSwipeAdapter<RecyclerViewAdapter.SimpleViewHolder> {
public static class SimpleViewHolder extends RecyclerView.ViewHolder {
SwipeLayout swipeLayout;
TextView textViewPos;
TextView textViewData;
Button buttonDelete;
public SimpleViewHolder(View itemView) {
super(itemView);
swipeLayout = (SwipeLayout) itemView.findViewById(R.id.swipe);
textViewPos = (TextView) itemView.findViewById(R.id.position);
textViewData = (TextView) itemView.findViewById(R.id.text_data);
buttonDelete = (Button) itemView.findViewById(R.id.delete);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(getClass().getSimpleName(), "onItemSelected: " + textViewData.getText().toString());
Toast.makeText(view.getContext(), "onItemSelected: " + textViewData.getText().toString(), Toast.LENGTH_SHORT).show();
}
});
}
}
private Context mContext;
private ArrayList<String> mDataset;
//protected SwipeItemRecyclerMangerImpl mItemManger = new SwipeItemRecyclerMangerImpl(this);
public RecyclerViewAdapter(Context context, ArrayList<String> objects) {
this.mContext = context;
this.mDataset = objects;
}
@Override
public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_item, parent, false);
return new SimpleViewHolder(view);
}
@Override
public void onBindViewHolder(final SimpleViewHolder viewHolder, final int position) {
String item = mDataset.get(position);
viewHolder.swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
viewHolder.swipeLayout.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onOpen(SwipeLayout layout) {
YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
}
});
viewHolder.swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {
@Override
public void onDoubleClick(SwipeLayout layout, boolean surface) {
Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
}
});
viewHolder.buttonDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mItemManger.removeShownLayouts(viewHolder.swipeLayout);
mDataset.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, mDataset.size());
mItemManger.closeAllItems();
Toast.makeText(view.getContext(), "Deleted " + viewHolder.textViewData.getText().toString() + "!", Toast.LENGTH_SHORT).show();
}
});
viewHolder.textViewPos.setText((position + 1) + ".");
viewHolder.textViewData.setText(item);
mItemManger.bind(viewHolder.itemView, position);
}
@Override
public int getItemCount() {
return mDataset.size();
}
@Override
public int getSwipeLayoutResourceId(int position) {
return R.id.swipe;
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java
================================================
package com.daimajia.swipedemo.adapter.util;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private Drawable mDivider;
private boolean mShowFirstDivider = false;
private boolean mShowLastDivider = false;
public DividerItemDecoration(Context context, AttributeSet attrs) {
final TypedArray a = context
.obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
mDivider = a.getDrawable(0);
a.recycle();
}
public DividerItemDecoration(Context context, AttributeSet attrs, boolean showFirstDivider,
boolean showLastDivider) {
this(context, attrs);
mShowFirstDivider = showFirstDivider;
mShowLastDivider = showLastDivider;
}
public DividerItemDecoration(Drawable divider) {
mDivider = divider;
}
public DividerItemDecoration(Drawable divider, boolean showFirstDivider,
boolean showLastDivider) {
this(divider);
mShowFirstDivider = showFirstDivider;
mShowLastDivider = showLastDivider;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
if (mDivider == null) {
return;
}
if (parent.getChildPosition(view) < 1) {
return;
}
if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
outRect.top = mDivider.getIntrinsicHeight();
} else {
outRect.left = mDivider.getIntrinsicWidth();
}
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (mDivider == null) {
super.onDrawOver(c, parent, state);
return;
}
// Initialization needed to avoid compiler warning
int left = 0, right = 0, top = 0, bottom = 0, size;
int orientation = getOrientation(parent);
int childCount = parent.getChildCount();
if (orientation == LinearLayoutManager.VERTICAL) {
size = mDivider.getIntrinsicHeight();
left = parent.getPaddingLeft();
right = parent.getWidth() - parent.getPaddingRight();
} else { //horizontal
size = mDivider.getIntrinsicWidth();
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
}
for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
if (orientation == LinearLayoutManager.VERTICAL) {
top = child.getTop() - params.topMargin;
bottom = top + size;
} else { //horizontal
left = child.getLeft() - params.leftMargin;
right = left + size;
}
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
// show last divider
if (mShowLastDivider && childCount > 0) {
View child = parent.getChildAt(childCount - 1);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
if (orientation == LinearLayoutManager.VERTICAL) {
top = child.getBottom() + params.bottomMargin;
bottom = top + size;
} else { // horizontal
left = child.getRight() + params.rightMargin;
right = left + size;
}
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
private int getOrientation(RecyclerView parent) {
if (parent.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
return layoutManager.getOrientation();
} else {
throw new IllegalStateException(
"DividerItemDecoration can only be used with a LinearLayoutManager.");
}
}
}
================================================
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java
================================================
package com.daimajia.swipedemo.adapter.util;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
private OnItemClickListener mListener;
public interface OnItemClickListener {
public void onItemClick(View view, int position);
}
GestureDetector mGestureDetector;
public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
mListener = listener;
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
}
@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
View childView = view.findChildViewUnder(e.getX(), e.getY());
if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
mListener.onItemClick(childView, view.getChildPosition(childView));
}
return false;
}
@Override
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
}
================================================
FILE: demo/src/main/res/drawable/dark_gray.xml
================================================
<?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>
================================================
FILE: demo/src/main/res/drawable/divider.xml
================================================
<!--
~ Copyright (C) 2014 Lucas Rocha
~
~ 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#cccccc"/>
<size android:width="1dp"
android:height="1dp" />
</shape>
================================================
FILE: demo/src/main/res/drawable/item_selector.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/backgroundColorPress" android:state_pressed="true"/>
<item android:drawable="@color/backgroundColorPress" android:state_focused="true"/>
<item android:drawable="@color/backgroundColor"/>
</selector>
================================================
FILE: demo/src/main/res/drawable/red.xml
================================================
<?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>
================================================
FILE: demo/src/main/res/drawable/white.xml
================================================
<?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>
================================================
FILE: demo/src/main/res/layout/complicate_layout.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<include layout="@layout/sampe_nested_scrollview" android:layout_height="80dp" android:layout_width="match_parent"/>
<include layout="@layout/sampe_nested_seekbar" android:layout_height="80dp" android:layout_width="match_parent" android:layout_marginTop="20dp"/>
<include layout="@layout/sampe_nested_edittext" android:layout_height="80dp" android:layout_width="match_parent" android:layout_marginTop="20dp"/>
<include layout="@layout/sample_nested_parent" android:layout_height="80dp" android:layout_width="match_parent" android:layout_marginTop="20dp"/>
</LinearLayout>
================================================
FILE: demo/src/main/res/layout/grid_item.xml
================================================
<?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>
================================================
FILE: demo/src/main/res/layout/gridview.xml
================================================
<?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/item_selector"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
================================================
FILE: demo/src/main/res/layout/listview.xml
================================================
<?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"/>
================================================
FILE: demo/src/main/res/layout/listview_item.xml
================================================
<?xml version="1.0" encoding="utf-8" ?>
<com.daimajia.swipe.SwipeLayout
xmlns:swipe="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
swipe:leftEdgeSwipeOffset="0dp"
swipe:rightEdgeSwipeOffset="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#FF5534"
android:gravity="center"
android:tag="Bottom3"
android:weightSum="10">
<ImageView
android:id="@+id/trash"
android:layout_width="27dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/trash" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:text="Delete Item?"
android:textColor="#fff"
android:textSize="17sp" />
<Button
android:id="@+id/delete"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:background="@drawable/white"
android:text="Yes,Delete"
android:textColor="#FF5534" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/item_selector"
android:padding="10dp">
<TextView
android:id="@+id/position"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/text_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="Hover"
android:text="Do not, for one repulse, forgo the purpose that you resolved to effort. " />
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/main.xml
================================================
<?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">
<ImageView
android:layout_gravity="left|right|top"
android:src="@drawable/bird"
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:id="@+id/bird_bottom"
android:layout_gravity="bottom"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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>
================================================
FILE: demo/src/main/res/layout/recyclerview.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- A RecyclerView with some commonly used attributes -->
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
================================================
FILE: demo/src/main/res/layout/recyclerview_item.xml
================================================
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.daimajia.swipe.SwipeLayout xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
swipe:leftEdgeSwipeOffset="0dp"
swipe:rightEdgeSwipeOffset="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#FF5534"
android:gravity="center"
android:tag="Bottom3"
android:weightSum="10">
<ImageView
android:id="@+id/trash"
android:layout_width="27dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/trash" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:text="Delete Item?"
android:textColor="#fff"
android:textSize="17sp" />
<Button
android:id="@+id/delete"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:background="#ffffff"
android:text="Yes,Delete"
android:textColor="#FF5534" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/item_selector"
android:elevation="5dp"
android:padding="10dp">
<TextView
android:id="@+id/position"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/text_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="Hover"/>
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
</LinearLayout>
================================================
FILE: demo/src/main/res/layout/sampe_nested_edittext.xml
================================================
<?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:layout_width="80dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/trash"
android:src="@drawable/trash"
android:layout_width="match_parent"
android:background="#FF3B30"
android:paddingLeft="25dp"
android:paddingRight="25dp"
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:text="EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_gravity="right"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/sampe_nested_scrollview.xml
================================================
<?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:layout_width="80dp"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="wrap_content">
<TextView
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
</LinearLayout>
<LinearLayout
android:padding="10dp"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="ScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ScrollView
android:layout_marginLeft="80dp"
android:layout_width="match_parent"
android:scrollbars="horizontal"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew.None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/hhhhh"
android:text="HelloWorld"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/sampe_nested_seekbar.xml
================================================
<?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:layout_width="80dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/trash"
android:src="@drawable/trash"
android:layout_width="match_parent"
android:background="#FF3B30"
android:paddingLeft="25dp"
android:paddingRight="25dp"
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:text="SeekBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<SeekBar
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/sample1.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp"
app:clickToClose="true">
<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:clickable="true"
android:background="@drawable/red"
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:tag="Bottom4"
android:id="@+id/bottom_wrapper_2"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/magnifier2"
android:src="@drawable/magnifier"
android:layout_width="70dp"
android:background="#f7e79c"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/star2"
android:src="@drawable/star"
android:layout_width="70dp"
android:background="#4cd964"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/trash2"
android:src="@drawable/trash"
android:layout_width="70dp"
android:background="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:tag="Bottom3"
android:id="@+id/starbott"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/bottom_wrapper_child1"
android:background="@drawable/dark_gray"
android:clickable="true"
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>
<TextView
android:padding="10dp"
android:background="@drawable/white"
android:tag="Hover"
android:text="要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/sample2.xml
================================================
<?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="@drawable/red"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:padding="10dp"
android:orientation="vertical"
android:background="@drawable/white"
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>
================================================
FILE: demo/src/main/res/layout/sample3.xml
================================================
<?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>
<TextView
android:padding="10dp"
android:background="#ffffff"
android:tag="Hover"
android:text="None is of freedom or of life deserving unless he daily conquers it anew. "
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.daimajia.swipe.SwipeLayout>
================================================
FILE: demo/src/main/res/layout/sample_nested_parent.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/parent_framelayout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">
<com.daimajia.swipe.SwipeLayout
android:id="@+id/test_swipe_swipe"
android:layout_width="match_parent" android:layout_height="80dp">
<LinearLayout
android:layout_width="80dp"
android:layout_height="match_parent">
<ImageView
android:id="@+id/trash"
android:src="@drawable/trash"
android:layout_width="match_parent"
android:background="#FF3B30"
android:paddingLeft="25dp"
android:paddingRight="25dp"
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:text="SeekBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</com.daimajia.swipe.SwipeLayout>
</FrameLayout>
================================================
FILE: demo/src/main/res/layout/sample_together.xml
================================================
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:padding="10dp">
<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>
================================================
FILE: demo/src/main/res/menu/my.xml
================================================
<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:orderInCategory="100"
android:title="ListView" />
<item
android:id="@+id/action_gridview"
android:orderInCategory="100"
android:title="GridView" />
<item
android:id="@+id/action_recycler"
android:orderInCategory="100"
android:title="RecyclerView" />
<item
android:id="@+id/action_nested"
android:title="Complicate" />
</menu>
================================================
FILE: demo/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="backgroundColor">#E8E8E0</color>
<color name="backgroundColorPress">#DBDBD3</color>
<color name="red">#FF3B00</color>
<color name="red_press">#990000</color>
<color name="dark_gray">#4C535B</color>
<color name="dark_gray_press">#ff7e8a97</color>
</resources>
================================================
FILE: demo/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: demo/src/main/res/values/strings.xml
================================================
<?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>
================================================
FILE: demo/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
================================================
FILE: demo/src/main/res/values-w820dp/dimens.xml
================================================
<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>
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Thu Mar 09 16:07:03 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
================================================
FILE: gradle.properties
================================================
# 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.2.0
VERSION_CODE=22
GROUP=com.daimajia.swipelayout
ANDROID_BUILD_MIN_SDK_VERSION=9
ANDROID_BUILD_TARGET_SDK_VERSION=25
ANDROID_BUILD_SDK_VERSION=25
ANDROID_BUILD_TOOLS_VERSION=25.0.2
================================================
FILE: gradlew
================================================
#!/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 "$@"
================================================
FILE: gradlew.bat
================================================
@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
================================================
FILE: library/.gitignore
================================================
/build
================================================
FILE: library/build.gradle
================================================
apply plugin: 'com.android.library'
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 9
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
}
dependencies {
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
}
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
}
================================================
FILE: library/gradle-mvn-push.gradle
================================================
/*
* 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 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
}
}
================================================
FILE: library/gradle.properties
================================================
# 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
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
================================================
FILE: library/proguard-rules.pro
================================================
# 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 *;
#}
================================================
FILE: library/src/main/AndroidManifest.xml
================================================
<manifest package="com.daimajia.swipe">
<application />
</manifest>
================================================
FILE: library/src/main/java/com/daimajia/swipe/SimpleSwipeListener.java
================================================
package com.daimajia.swipe;
public class SimpleSwipeListener implements SwipeLayout.SwipeListener {
@Override
public void onStartOpen(SwipeLayout layout) {
}
@Override
public void onOpen(SwipeLayout layout) {
}
@Override
public void onStartClose(SwipeLayout layout) {
}
@Override
public void onClose(SwipeLayout layout) {
}
@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
}
@Override
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/SwipeLayout.java
================================================
package com.daimajia.swipe;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class SwipeLayout extends FrameLayout {
@Deprecated
public static final int EMPTY_LAYOUT = -1;
private static final int DRAG_LEFT = 1;
private static final int DRAG_RIGHT = 2;
private static final int DRAG_TOP = 4;
private static final int DRAG_BOTTOM = 8;
private static final DragEdge DefaultDragEdge = DragEdge.Right;
private int mTouchSlop;
private DragEdge mCurrentDragEdge = DefaultDragEdge;
private ViewDragHelper mDragHelper;
private int mDragDistance = 0;
private LinkedHashMap<DragEdge, View> mDragEdges = new LinkedHashMap<>();
private ShowMode mShowMode;
private float[] mEdgeSwipesOffset = new float[4];
private List<SwipeListener> mSwipeListeners = new ArrayList<>();
private List<SwipeDenier> mSwipeDeniers = new ArrayList<>();
private Map<View, ArrayList<OnRevealListener>> mRevealListeners = new HashMap<>();
private Map<View, Boolean> mShowEntirely = new HashMap<>();
private Map<View, Rect> mViewBoundCache = new HashMap<>();//save all children's bound, restore in onLayout
private DoubleClickListener mDoubleClickListener;
private boolean mSwipeEnabled = true;
private boolean[] mSwipesEnabled = new boolean[]{true, true, true, true};
private boolean mClickToClose = false;
private float mWillOpenPercentAfterOpen = 0.75f;
private float mWillOpenPercentAfterClose = 0.25f;
public enum DragEdge {
Left,
Top,
Right,
Bottom
}
public enum ShowMode {
LayDown,
PullOut
}
public SwipeLayout(Context context) {
this(context, null);
}
public SwipeLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SwipeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mDragHelper = ViewDragHelper.create(this, mDragHelperCallback);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeLayout);
int dragEdgeChoices = a.getInt(R.styleable.SwipeLayout_drag_edge, DRAG_RIGHT);
mEdgeSwipesOffset[DragEdge.Left.ordinal()] = a.getDimension(R.styleable.SwipeLayout_leftEdgeSwipeOffset, 0);
mEdgeSwipesOffset[DragEdge.Right.ordinal()] = a.getDimension(R.styleable.SwipeLayout_rightEdgeSwipeOffset, 0);
mEdgeSwipesOffset[DragEdge.Top.ordinal()] = a.getDimension(R.styleable.SwipeLayout_topEdgeSwipeOffset, 0);
mEdgeSwipesOffset[DragEdge.Bottom.ordinal()] = a.getDimension(R.styleable.SwipeLayout_bottomEdgeSwipeOffset, 0);
setClickToClose(a.getBoolean(R.styleable.SwipeLayout_clickToClose, mClickToClose));
if ((dragEdgeChoices & DRAG_LEFT) == DRAG_LEFT) {
mDragEdges.put(DragEdge.Left, null);
}
if ((dragEdgeChoices & DRAG_TOP) == DRAG_TOP) {
mDragEdges.put(DragEdge.Top, null);
}
if ((dragEdgeChoices & DRAG_RIGHT) == DRAG_RIGHT) {
mDragEdges.put(DragEdge.Right, null);
}
if ((dragEdgeChoices & DRAG_BOTTOM) == DRAG_BOTTOM) {
mDragEdges.put(DragEdge.Bottom, null);
}
int ordinal = a.getInt(R.styleable.SwipeLayout_show_mode, ShowMode.PullOut.ordinal());
mShowMode = ShowMode.values()[ordinal];
a.recycle();
}
public interface SwipeListener {
void onStartOpen(SwipeLayout layout);
void onOpen(SwipeLayout layout);
void onStartClose(SwipeLayout layout);
void onClose(SwipeLayout layout);
void onUpdate(SwipeLayout layout, int leftOffset, int topOffset);
void onHandRelease(SwipeLayout layout, float xvel, float yvel);
}
public void addSwipeListener(SwipeListener l) {
mSwipeListeners.add(l);
}
public void removeSwipeListener(SwipeListener l) {
mSwipeListeners.remove(l);
}
public void removeAllSwipeListener() {
mSwipeListeners.clear();
}
public interface SwipeDenier {
/*
* Called in onInterceptTouchEvent Determines if this swipe event should
* be denied Implement this interface if you are using views with swipe
* gestures As a child of SwipeLayout
*
* @return true deny false allow
*/
boolean shouldDenySwipe(MotionEvent ev);
}
public void addSwipeDenier(SwipeDenier denier) {
mSwipeDeniers.add(denier);
}
public void removeSwipeDenier(SwipeDenier denier) {
mSwipeDeniers.remove(denier);
}
public void removeAllSwipeDeniers() {
mSwipeDeniers.clear();
}
public interface OnRevealListener {
void onReveal(View child, DragEdge edge, float fraction, int distance);
}
/**
* bind a view with a specific
* {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
*
* @param childId the view id.
* @param l the target
* {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
*/
public void addRevealListener(int childId, OnRevealListener l) {
View child = findViewById(childId);
if (child == null) {
throw new IllegalArgumentException("Child does not belong to SwipeListener.");
}
if (!mShowEntirely.containsKey(child)) {
mShowEntirely.put(child, false);
}
if (mRevealListeners.get(child) == null)
mRevealListeners.put(child, new ArrayList<OnRevealListener>());
mRevealListeners.get(child).add(l);
}
/**
* bind multiple views with an
* {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}.
*
* @param childIds the view id.
* @param l the {@link com.daimajia.swipe.SwipeLayout.OnRevealListener}
*/
public void addRevealListener(int[] childIds, OnRevealListener l) {
for (int i : childIds)
addRevealListener(i, l);
}
public void removeRevealListener(int childId, OnRevealListener l) {
View child = findViewById(childId);
if (child == null) return;
mShowEntirely.remove(child);
if (mRevealListeners.containsKey(child)) mRevealListeners.get(child).remove(l);
}
public void removeAllRevealListeners(int childId) {
View child = findViewById(childId);
if (child != null) {
mRevealListeners.remove(child);
mShowEntirely.remove(child);
}
}
private ViewDragHelper.Callback mDragHelperCallback = new ViewDragHelper.Callback() {
@Override
public int clampViewPositionHorizontal(View child, int left, int dx) {
if (child == getSurfaceView()) {
switch (mCurrentDragEdge) {
case Top:
case Bottom:
return getPaddingLeft();
case Left:
if (left < getPaddingLeft()) return getPaddingLeft();
if (left > getPaddingLeft() + mDragDistance)
return getPaddingLeft() + mDragDistance;
break;
case Right:
if (left > getPaddingLeft()) return getPaddingLeft();
if (left < getPaddingLeft() - mDragDistance)
return getPaddingLeft() - mDragDistance;
break;
}
} else if (getCurrentBottomView() == child) {
switch (mCurrentDragEdge) {
case Top:
case Bottom:
return getPaddingLeft();
case Left:
if (mShowMode == ShowMode.PullOut) {
if (left > getPaddingLeft()) return getPaddingLeft();
}
break;
case Right:
if (mShowMode == ShowMode.PullOut) {
if (left < getMeasuredWidth() - mDragDistance) {
return getMeasuredWidth() - mDragDistance;
}
}
break;
}
}
return left;
}
@Override
public int clampViewPositionVertical(View child, int top, int dy) {
if (child == getSurfaceView()) {
switch (mCurrentDragEdge) {
case Left:
case Right:
return getPaddingTop();
case Top:
if (top < getPaddingTop()) return getPaddingTop();
if (top > getPaddingTop() + mDragDistance)
return getPaddingTop() + mDragDistance;
break;
case Bottom:
if (top < getPaddingTop() - mDragDistance) {
return getPaddingTop() - mDragDistance;
}
if (top > getPaddingTop()) {
return getPaddingTop();
}
}
} else {
View surfaceView = getSurfaceView();
int surfaceViewTop = surfaceView == null ? 0 : surfaceView.getTop();
switch (mCurrentDragEdge) {
case Left:
case Right:
return getPaddingTop();
case Top:
if (mShowMode == ShowMode.PullOut) {
if (top > getPaddingTop()) return getPaddingTop();
} else {
if (surfaceViewTop + dy < getPaddingTop())
return getPaddingTop();
if (surfaceViewTop + dy > getPaddingTop() + mDragDistance)
return getPaddingTop() + mDragDistance;
}
break;
case Bottom:
if (mShowMode == ShowMode.PullOut) {
if (top < getMeasuredHeight() - mDragDistance)
return getMeasuredHeight() - mDragDistance;
} else {
if (surfaceViewTop + dy >= getPaddingTop())
return getPaddingTop();
if (surfaceViewTop + dy <= getPaddingTop() - mDragDistance)
return getPaddingTop() - mDragDistance;
}
}
}
return top;
}
@Override
public boolean tryCaptureView(View child, int pointerId) {
boolean result = child == getSurfaceView() || getBottomViews().contains(child);
if (result) {
isCloseBeforeDrag = getOpenStatus() == Status.Close;
}
return result;
}
@Override
public int getViewHorizontalDragRange(View child) {
return mDragDistance;
}
@Override
public int getViewVerticalDragRange(View child) {
return mDragDistance;
}
boolean isCloseBeforeDrag = true;
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) {
super.onViewReleased(releasedChild, xvel, yvel);
processHandRelease(xvel, yvel, isCloseBeforeDrag);
for (SwipeListener l : mSwipeListeners) {
l.onHandRelease(SwipeLayout.this, xvel, yvel);
}
invalidate();
}
@Override
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
View surfaceView = getSurfaceView();
if (surfaceView == null) return;
View currentBottomView = getCurrentBottomView();
int evLeft = surfaceView.getLeft(),
evRight = surfaceView.getRight(),
evTop = surfaceView.getTop(),
evBottom = surfaceView.getBottom();
if (changedView == surfaceView) {
if (mShowMode == ShowMode.PullOut && currentBottomView != null) {
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
currentBottomView.offsetLeftAndRight(dx);
} else {
currentBottomView.offsetTopAndBottom(dy);
}
}
} else if (getBottomViews().contains(changedView)) {
if (mShowMode == ShowMode.PullOut) {
surfaceView.offsetLeftAndRight(dx);
surfaceView.offsetTopAndBottom(dy);
} else {
Rect rect = computeBottomLayDown(mCurrentDragEdge);
if (currentBottomView != null) {
currentBottomView.layout(rect.left, rect.top, rect.right, rect.bottom);
}
int newLeft = surfaceView.getLeft() + dx, newTop = surfaceView.getTop() + dy;
if (mCurrentDragEdge == DragEdge.Left && newLeft < getPaddingLeft())
newLeft = getPaddingLeft();
else if (mCurrentDragEdge == DragEdge.Right && newLeft > getPaddingLeft())
newLeft = getPaddingLeft();
else if (mCurrentDragEdge == DragEdge.Top && newTop < getPaddingTop())
newTop = getPaddingTop();
else if (mCurrentDragEdge == DragEdge.Bottom && newTop > getPaddingTop())
newTop = getPaddingTop();
surfaceView.layout(newLeft, newTop, newLeft + getMeasuredWidth(), newTop + getMeasuredHeight());
}
}
dispatchRevealEvent(evLeft, evTop, evRight, evBottom);
dispatchSwipeEvent(evLeft, evTop, dx, dy);
invalidate();
captureChildrenBound();
}
};
/**
* save children's bounds, so they can restore the bound in {@link #onLayout(boolean, int, int, int, int)}
*/
private void captureChildrenBound() {
View currentBottomView = getCurrentBottomView();
if (getOpenStatus() == Status.Close) {
mViewBoundCache.remove(currentBottomView);
return;
}
View[] views = new View[]{getSurfaceView(), currentBottomView};
for (View child : views) {
Rect rect = mViewBoundCache.get(child);
if (rect == null) {
rect = new Rect();
mViewBoundCache.put(child, rect);
}
rect.left = child.getLeft();
rect.top = child.getTop();
rect.right = child.getRight();
rect.bottom = child.getBottom();
}
}
/**
* the dispatchRevealEvent method may not always get accurate position, it
* makes the view may not always get the event when the view is totally
* show( fraction = 1), so , we need to calculate every time.
*/
protected boolean isViewTotallyFirstShowed(View child, Rect relativePosition, DragEdge edge, int surfaceLeft,
int surfaceTop, int surfaceRight, int surfaceBottom) {
if (mShowEntirely.get(child)) return false;
int childLeft = relativePosition.left;
int childRight = relativePosition.right;
int childTop = relativePosition.top;
int childBottom = relativePosition.bottom;
boolean r = false;
if (getShowMode() == ShowMode.LayDown) {
if ((edge == DragEdge.Right && surfaceRight <= childLeft)
|| (edge == DragEdge.Left && surfaceLeft >= childRight)
|| (edge == DragEdge.Top && surfaceTop >= childBottom)
|| (edge == DragEdge.Bottom && surfaceBottom <= childTop)) r = true;
} else if (getShowMode() == ShowMode.PullOut) {
if ((edge == DragEdge.Right && childRight <= getWidth())
|| (edge == DragEdge.Left && childLeft >= getPaddingLeft())
|| (edge == DragEdge.Top && childTop >= getPaddingTop())
|| (edge == DragEdge.Bottom && childBottom <= getHeight())) r = true;
}
return r;
}
protected boolean isViewShowing(View child, Rect relativePosition, DragEdge availableEdge, int surfaceLeft,
int surfaceTop, int surfaceRight, int surfaceBottom) {
int childLeft = relativePosition.left;
int childRight = relativePosition.right;
int childTop = relativePosition.top;
int childBottom = relativePosition.bottom;
if (getShowMode() == ShowMode.LayDown) {
switch (availableEdge) {
case Right:
if (surfaceRight > childLeft && surfaceRight <= childRight) {
return true;
}
break;
case Left:
if (surfaceLeft < childRight && surfaceLeft >= childLeft) {
return true;
}
break;
case Top:
if (surfaceTop >= childTop && surfaceTop < childBottom) {
return true;
}
break;
case Bottom:
if (surfaceBottom > childTop && surfaceBottom <= childBottom) {
return true;
}
break;
}
} else if (getShowMode() == ShowMode.PullOut) {
switch (availableEdge) {
case Right:
if (childLeft <= getWidth() && childRight > getWidth()) return true;
break;
case Left:
if (childRight >= getPaddingLeft() && childLeft < getPaddingLeft()) return true;
break;
case Top:
if (childTop < getPaddingTop() && childBottom >= getPaddingTop()) return true;
break;
case Bottom:
if (childTop < getHeight() && childTop >= getPaddingTop()) return true;
break;
}
}
return false;
}
protected Rect getRelativePosition(View child) {
View t = child;
Rect r = new Rect(t.getLeft(), t.getTop(), 0, 0);
while (t.getParent() != null && t != getRootView()) {
t = (View) t.getParent();
if (t == this) break;
r.left += t.getLeft();
r.top += t.getTop();
}
r.right = r.left + child.getMeasuredWidth();
r.bottom = r.top + child.getMeasuredHeight();
return r;
}
private int mEventCounter = 0;
protected void dispatchSwipeEvent(int surfaceLeft, int surfaceTop, int dx, int dy) {
DragEdge edge = getDragEdge();
boolean open = true;
if (edge == DragEdge.Left) {
if (dx < 0) open = false;
} else if (edge == DragEdge.Right) {
if (dx > 0) open = false;
} else if (edge == DragEdge.Top) {
if (dy < 0) open = false;
} else if (edge == DragEdge.Bottom) {
if (dy > 0) open = false;
}
dispatchSwipeEvent(surfaceLeft, surfaceTop, open);
}
protected void dispatchSwipeEvent(int surfaceLeft, int surfaceTop, boolean open) {
safeBottomView();
Status status = getOpenStatus();
if (!mSwipeListeners.isEmpty()) {
mEventCounter++;
for (SwipeListener l : mSwipeListeners) {
if (mEventCounter == 1) {
if (open) {
l.onStartOpen(this);
} else {
l.onStartClose(this);
}
}
l.onUpdate(SwipeLayout.this, surfaceLeft - getPaddingLeft(), surfaceTop - getPaddingTop());
}
if (status == Status.Close) {
for (SwipeListener l : mSwipeListeners) {
l.onClose(SwipeLayout.this);
}
mEventCounter = 0;
}
if (status == Status.Open) {
View currentBottomView = getCurrentBottomView();
if (currentBottomView != null) {
currentBottomView.setEnabled(true);
}
for (SwipeListener l : mSwipeListeners) {
l.onOpen(SwipeLayout.this);
}
mEventCounter = 0;
}
}
}
/**
* prevent bottom view get any touch event. Especially in LayDown mode.
*/
private void safeBottomView() {
Status status = getOpenStatus();
List<View> bottoms = getBottomViews();
if (status == Status.Close) {
for (View bottom : bottoms) {
if (bottom != null && bottom.getVisibility() != INVISIBLE) {
bottom.setVisibility(INVISIBLE);
}
}
} else {
View currentBottomView = getCurrentBottomView();
if (currentBottomView != null && currentBottomView.getVisibility() != VISIBLE) {
currentBottomView.setVisibility(VISIBLE);
}
}
}
protected void dispatchRevealEvent(final int surfaceLeft, final int surfaceTop, final int surfaceRight,
final int surfaceBottom) {
if (mRevealListeners.isEmpty()) return;
for (Map.Entry<View, ArrayList<OnRevealListener>> entry : mRevealListeners.entrySet()) {
View child = entry.getKey();
Rect rect = getRelativePosition(child);
if (isViewShowing(child, rect, mCurrentDragEdge, surfaceLeft, surfaceTop,
surfaceRight, surfaceBottom)) {
mShowEntirely.put(child, false);
int distance = 0;
float fraction = 0f;
if (getShowMode() == ShowMode.LayDown) {
switch (mCurrentDragEdge) {
case Left:
distance = rect.left - surfaceLeft;
fraction = distance / (float) child.getWidth();
break;
case Right:
distance = rect.right - surfaceRight;
fraction = distance / (float) child.getWidth();
break;
case Top:
distance = rect.top - surfaceTop;
fraction = distance / (float) child.getHeight();
break;
case Bottom:
distance = rect.bottom - surfaceBottom;
fraction = distance / (float) child.getHeight();
break;
}
} else if (getShowMode() == ShowMode.PullOut) {
switch (mCurrentDragEdge) {
case Left:
distance = rect.right - getPaddingLeft();
fraction = distance / (float) child.getWidth();
break;
case Right:
distance = rect.left - getWidth();
fraction = distance / (float) child.getWidth();
break;
case Top:
distance = rect.bottom - getPaddingTop();
fraction = distance / (float) child.getHeight();
break;
case Bottom:
distance = rect.top - getHeight();
fraction = distance / (float) child.getHeight();
break;
}
}
for (OnRevealListener l : entry.getValue()) {
l.onReveal(child, mCurrentDragEdge, Math.abs(fraction), distance);
if (Math.abs(fraction) == 1) {
mShowEntirely.put(child, true);
}
}
}
if (isViewTotallyFirstShowed(child, rect, mCurrentDragEdge, surfaceLeft, surfaceTop,
surfaceRight, surfaceBottom)) {
mShowEntirely.put(child, true);
for (OnRevealListener l : entry.getValue()) {
if (mCurrentDragEdge == DragEdge.Left
|| mCurrentDragEdge == DragEdge.Right)
l.onReveal(child, mCurrentDragEdge, 1, child.getWidth());
else
l.onReveal(child, mCurrentDragEdge, 1, child.getHeight());
}
}
}
}
@Override
public void computeScroll() {
super.computeScroll();
if (mDragHelper.continueSettling(true)) {
ViewCompat.postInvalidateOnAnimation(this);
}
}
/**
* {@link android.view.View.OnLayoutChangeListener} added in API 11. I need
* to support it from API 8.
*/
public interface OnLayout {
void onLayout(SwipeLayout v);
}
private List<OnLayout> mOnLayoutListeners;
public void addOnLayoutListener(OnLayout l) {
if (mOnLayoutListeners == null) mOnLayoutListeners = new ArrayList<OnLayout>();
mOnLayoutListeners.add(l);
}
public void removeOnLayoutListener(OnLayout l) {
if (mOnLayoutListeners != null) mOnLayoutListeners.remove(l);
}
public void clearDragEdge() {
mDragEdges.clear();
}
public void setDrag(DragEdge dragEdge, int childId) {
clearDragEdge();
addDrag(dragEdge, childId);
}
public void setDrag(DragEdge dragEdge, View child) {
clearDragEdge();
addDrag(dragEdge, child);
}
public void addDrag(DragEdge dragEdge, int childId) {
addDrag(dragEdge, findViewById(childId), null);
}
public void addDrag(DragEdge dragEdge, View child) {
addDrag(dragEdge, child, null);
}
public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutParams params) {
if (child == null) return;
if (params == null) {
params = generateDefaultLayoutParams();
}
if (!checkLayoutParams(params)) {
params = generateLayoutParams(params);
}
int gravity = -1;
switch (dragEdge) {
case Left:
gravity = Gravity.LEFT;
break;
case Right:
gravity = Gravity.RIGHT;
break;
case Top:
gravity = Gravity.TOP;
break;
case Bottom:
gravity = Gravity.BOTTOM;
break;
}
if (params instanceof FrameLayout.LayoutParams) {
((LayoutParams) params).gravity = gravity;
}
addView(child, 0, params);
}
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child == null) return;
int gravity = Gravity.NO_GRAVITY;
try {
gravity = (Integer) params.getClass().getField("gravity").get(params);
} catch (Exception e) {
e.printStackTrace();
}
if (gravity > 0) {
gravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
mDragEdges.put(DragEdge.Left, child);
}
if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
mDragEdges.put(DragEdge.Right, child);
}
if ((gravity & Gravity.TOP) == Gravity.TOP) {
mDragEdges.put(DragEdge.Top, child);
}
if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
mDragEdges.put(DragEdge.Bottom, child);
}
} else {
for (Map.Entry<DragEdge, View> entry : mDragEdges.entrySet()) {
if (entry.getValue() == null) {
//means used the drag_edge attr, the no gravity child should be use set
mDragEdges.put(entry.getKey(), child);
break;
}
}
}
if (child.getParent() == this) {
return;
}
super.addView(child, index, params);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
updateBottomViews();
if (mOnLayoutListeners != null) for (int i = 0; i < mOnLayoutListeners.size(); i++) {
mOnLayoutListeners.get(i).onLayout(this);
}
}
void layoutPullOut() {
View surfaceView = getSurfaceView();
Rect surfaceRect = mViewBoundCache.get(surfaceView);
if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
if (surfaceView != null) {
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
bringChildToFront(surfaceView);
}
View currentBottomView = getCurrentBottomView();
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
if (bottomViewRect == null)
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, surfaceRect);
if (currentBottomView != null) {
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
}
}
void layoutLayDown() {
View surfaceView = getSurfaceView();
Rect surfaceRect = mViewBoundCache.get(surfaceView);
if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
if (surfaceView != null) {
surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
bringChildToFront(surfaceView);
}
View currentBottomView = getCurrentBottomView();
Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
if (bottomViewRect == null)
bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
if (currentBottomView != null) {
currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
}
}
private boolean mIsBeingDragged;
private void checkCanDrag(MotionEvent ev) {
if (mIsBeingDragged) return;
if (getOpenStatus() == Status.Middle) {
mIsBeingDragged = true;
return;
}
Status status = getOpenStatus();
float distanceX = ev.getRawX() - sX;
float distanceY = ev.getRawY() - sY;
float angle = Math.abs(distanceY / distanceX);
angle = (float) Math.toDegrees(Math.atan(angle));
if (getOpenStatus() == Status.Close) {
DragEdge dragEdge;
if (angle < 45) {
if (distanceX > 0 && isLeftSwipeEnabled()) {
dragEdge = DragEdge.Left;
} else if (distanceX < 0 && isRightSwipeEnabled()) {
dragEdge = DragEdge.Right;
} else return;
} else {
if (distanceY > 0 && isTopSwipeEnabled()) {
dragEdge = DragEdge.Top;
} else if (distanceY < 0 && isBottomSwipeEnabled()) {
dragEdge = DragEdge.Bottom;
} else return;
}
setCurrentDragEdge(dragEdge);
}
boolean doNothing = false;
if (mCurrentDragEdge == DragEdge.Right) {
boolean suitable = (status == Status.Open && distanceX > mTouchSlop)
|| (status == Status.Close && distanceX < -mTouchSlop);
suitable = suitable || (status == Status.Middle);
if (angle > 30 || !suitable) {
doNothing = true;
}
}
if (mCurrentDragEdge == DragEdge.Left) {
boolean suitable = (status == Status.Open && distanceX < -mTouchSlop)
|| (status == Status.Close && distanceX > mTouchSlop);
suitable = suitable || status == Status.Middle;
if (angle > 30 || !suitable) {
doNothing = true;
}
}
if (mCurrentDragEdge == DragEdge.Top) {
boolean suitable = (status == Status.Open && distanceY < -mTouchSlop)
|| (status == Status.Close && distanceY > mTouchSlop);
suitable = suitable || status == Status.Middle;
if (angle < 60 || !suitable) {
doNothing = true;
}
}
if (mCurrentDragEdge == DragEdge.Bottom) {
boolean suitable = (status == Status.Open && distanceY > mTouchSlop)
|| (status == Status.Close && distanceY < -mTouchSlop);
suitable = suitable || status == Status.Middle;
if (angle < 60 || !suitable) {
doNothing = true;
}
}
mIsBeingDragged = !doNothing;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!isSwipeEnabled()) {
return false;
}
if (mClickToClose && getOpenStatus() == Status.Open && isTouchOnSurface(ev)) {
return true;
}
for (SwipeDenier denier : mSwipeDeniers) {
if (denier != null && denier.shouldDenySwipe(ev)) {
return false;
}
}
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mDragHelper.processTouchEvent(ev);
mIsBeingDragged = false;
sX = ev.getRawX();
sY = ev.getRawY();
//if the swipe is in middle state(scrolling), should intercept the touch
if (getOpenStatus() == Status.Middle) {
mIsBeingDragged = true;
}
break;
case MotionEvent.ACTION_MOVE:
boolean beforeCheck = mIsBeingDragged;
checkCanDrag(ev);
if (mIsBeingDragged) {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
}
if (!beforeCheck && mIsBeingDragged) {
//let children has one chance to catch the touch, and request the swipe not intercept
//useful when swipeLayout wrap a swipeLayout or other gestural layout
return false;
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
mIsBeingDragged = false;
mDragHelper.processTouchEvent(ev);
break;
default://handle other action, such as ACTION_POINTER_DOWN/UP
mDragHelper.processTouchEvent(ev);
}
return mIsBeingDragged;
}
private float sX = -1, sY = -1;
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isSwipeEnabled()) return super.onTouchEvent(event);
int action = event.getActionMasked();
gestureDetector.onTouchEvent(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
mDragHelper.processTouchEvent(event);
sX = event.getRawX();
sY = event.getRawY();
case MotionEvent.ACTION_MOVE: {
//the drag state and the direction are already judged at onInterceptTouchEvent
checkCanDrag(event);
if (mIsBeingDragged) {
getParent().requestDisallowInterceptTouchEvent(true);
mDragHelper.processTouchEvent(event);
}
break;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mDragHelper.processTouchEvent(event);
break;
default://handle other action, such as ACTION_POINTER_DOWN/UP
mDragHelper.processTouchEvent(event);
}
return super.onTouchEvent(event) || mIsBeingDragged || action == MotionEvent.ACTION_DOWN;
}
public boolean isClickToClose() {
return mClickToClose;
}
public void setClickToClose(boolean mClickToClose) {
this.mClickToClose = mClickToClose;
}
public void setSwipeEnabled(boolean enabled) {
mSwipeEnabled = enabled;
}
public boolean isSwipeEnabled() {
return mSwipeEnabled;
}
public boolean isLeftSwipeEnabled() {
View bottomView = mDragEdges.get(DragEdge.Left);
return bottomView != null && bottomView.getParent() == this
&& bottomView != getSurfaceView() && mSwipesEnabled[DragEdge.Left.ordinal()];
}
public void setLeftSwipeEnabled(boolean leftSwipeEnabled) {
this.mSwipesEnabled[DragEdge.Left.ordinal()] = leftSwipeEnabled;
}
public boolean isRightSwipeEnabled() {
View bottomView = mDragEdges.get(DragEdge.Right);
return bottomView != null && bottomView.getParent() == this
&& bottomView != getSurfaceView() && mSwipesEnabled[DragEdge.Right.ordinal()];
}
public void setRightSwipeEnabled(boolean rightSwipeEnabled) {
this.mSwipesEnabled[DragEdge.Right.ordinal()] = rightSwipeEnabled;
}
public boolean isTopSwipeEnabled() {
View bottomView = mDragEdges.get(DragEdge.Top);
return bottomView != null && bottomView.getParent() == this
&& bottomView != getSurfaceView() && mSwipesEnabled[DragEdge.Top.ordinal()];
}
public void setTopSwipeEnabled(boolean topSwipeEnabled) {
this.mSwipesEnabled[DragEdge.Top.ordinal()] = topSwipeEnabled;
}
public boolean isBottomSwipeEnabled() {
View bottomView = mDragEdges.get(DragEdge.Bottom);
return bottomView != null && bottomView.getParent() == this
&& bottomView != getSurfaceView() && mSwipesEnabled[DragEdge.Bottom.ordinal()];
}
public void setBottomSwipeEnabled(boolean bottomSwipeEnabled) {
this.mSwipesEnabled[DragEdge.Bottom.ordinal()] = bottomSwipeEnabled;
}
/***
* Returns the percentage of revealing at which the view below should the view finish opening
* if it was already open before dragging
*
* @returns The percentage of view revealed to trigger, default value is 0.25
*/
public float getWillOpenPercentAfterOpen() {
return mWillOpenPercentAfterOpen;
}
/***
* Allows to stablish at what percentage of revealing the view below should the view finish opening
* if it was already open before dragging
*
* @param willOpenPercentAfterOpen The percentage of view revealed to trigger, default value is 0.25
*/
public void setWillOpenPercentAfterOpen(float willOpenPercentAfterOpen) {
this.mWillOpenPercentAfterOpen = willOpenPercentAfterOpen;
}
/***
* Returns the percentage of revealing at which the view below should the view finish opening
* if it was already closed before dragging
*
* @returns The percentage of view revealed to trigger, default value is 0.25
*/
public float getWillOpenPercentAfterClose() {
return mWillOpenPercentAfterClose;
}
/***
* Allows to stablish at what percentage of revealing the view below should the view finish opening
* if it was already closed before dragging
*
* @param willOpenPercentAfterClose The percentage of view revealed to trigger, default value is 0.75
*/
public void setWillOpenPercentAfterClose(float willOpenPercentAfterClose) {
this.mWillOpenPercentAfterClose = willOpenPercentAfterClose;
}
private boolean insideAdapterView() {
return getAdapterView() != null;
}
private AdapterView getAdapterView() {
ViewParent t = getParent();
if (t instanceof AdapterView) {
return (AdapterView) t;
}
return null;
}
private void performAdapterViewItemClick() {
if (getOpenStatus() != Status.Close) return;
ViewParent t = getParent();
if (t instanceof AdapterView) {
AdapterView view = (AdapterView) t;
int p = view.getPositionForView(SwipeLayout.this);
if (p != AdapterView.INVALID_POSITION) {
view.performItemClick(view.getChildAt(p - view.getFirstVisiblePosition()), p, view
.getAdapter().getItemId(p));
}
}
}
private boolean performAdapterViewItemLongClick() {
if (getOpenStatus() != Status.Close) return false;
ViewParent t = getParent();
if (t instanceof AdapterView) {
AdapterView view = (AdapterView) t;
int p = view.getPositionForView(SwipeLayout.this);
if (p == AdapterView.INVALID_POSITION) return false;
long vId = view.getItemIdAtPosition(p);
boolean handled = false;
try {
Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
m.setAccessible(true);
handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);
} catch (Exception e) {
e.printStackTrace();
if (view.getOnItemLongClickListener() != null) {
handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
}
if (handled) {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
}
return handled;
}
return false;
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (insideAdapterView()) {
if (clickListener == null) {
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
performAdapterViewItemClick();
}
});
}
if (longClickListener == null) {
setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
performAdapterViewItemLongClick();
return true;
}
});
}
}
}
OnClickListener clickListener;
@Override
public void setOnClickListener(OnClickListener l) {
super.setOnClickListener(l);
clickListener = l;
}
OnLongClickListener longClickListener;
@Override
public void setOnLongClickListener(OnLongClickListener l) {
super.setOnLongClickListener(l);
longClickListener = l;
}
private Rect hitSurfaceRect;
private boolean isTouchOnSurface(MotionEvent ev) {
View surfaceView = getSurfaceView();
if (surfaceView == null) {
return false;
}
if (hitSurfaceRect == null) {
hitSurfaceRect = new Rect();
}
surfaceView.getHitRect(hitSurfaceRect);
return hitSurfaceRect.contains((int) ev.getX(), (int) ev.getY());
}
private GestureDetector gestureDetector = new GestureDetector(getContext(), new SwipeDetector());
class SwipeDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (mClickToClose && isTouchOnSurface(e)) {
close();
}
return super.onSingleTapUp(e);
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if (mDoubleClickListener != null) {
View target;
View bottom = getCurrentBottomView();
View surface = getSurfaceView();
if (bottom != null && e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
&& e.getY() > bottom.getTop() && e.getY() < bottom.getBottom()) {
target = bottom;
} else {
target = surface;
}
mDoubleClickListener.onDoubleClick(SwipeLayout.this, target == surface);
}
return true;
}
}
/**
* set the drag distance, it will force set the bottom view's width or
* height via this value.
*
* @param max max distance in dp unit
*/
public void setDragDistance(int max) {
if (max < 0) max = 0;
mDragDistance = dp2px(max);
requestLayout();
}
/**
* There are 2 diffirent show mode.
* {@link com.daimajia.swipe.SwipeLayout.ShowMode}.PullOut and
* {@link com.daimajia.swipe.SwipeLayout.ShowMode}.LayDown.
*
* @param mode
*/
public void setShowMode(ShowMode mode) {
mShowMode = mode;
requestLayout();
}
public DragEdge getDragEdge() {
return mCurrentDragEdge;
}
public int getDragDistance() {
return mDragDistance;
}
public ShowMode getShowMode() {
return mShowMode;
}
/**
* return null if there is no surface view(no children)
*/
public View getSurfaceView() {
if (getChildCount() == 0) return null;
return getChildAt(getChildCount() - 1);
}
/**
* return null if there is no bottom view
*/
public View getCurrentBottomView() {
List<View> bottoms = getBottomViews();
if (mCurrentDragEdge.ordinal() < bottoms.size()) {
return bottoms.get(mCurrentDragEdge.ordinal());
}
return null;
}
/**
* @return all bottomViews: left, top, right, bottom (may null if the edge is not set)
*/
public List<View> getBottomViews() {
ArrayList<View> bottoms = new ArrayList<View>();
for (DragEdge dragEdge : DragEdge.values()) {
bottoms.add(mDragEdges.get(dragEdge));
}
return bottoms;
}
public enum Status {
Middle,
Open,
Close
}
/**
* get the open status.
*
* @return {@link com.daimajia.swipe.SwipeLayout.Status} Open , Close or
* Middle.
*/
public Status getOpenStatus() {
View surfaceView = getSurfaceView();
if (surfaceView == null) {
return Status.Close;
}
int surfaceLeft = surfaceView.getLeft();
int surfaceTop = surfaceView.getTop();
if (surfaceLeft == getPaddingLeft() && surfaceTop == getPaddingTop()) return Status.Close;
if (surfaceLeft == (getPaddingLeft() - mDragDistance) || surfaceLeft == (getPaddingLeft() + mDragDistance)
|| surfaceTop == (getPaddingTop() - mDragDistance) || surfaceTop == (getPaddingTop() + mDragDistance))
return Status.Open;
return Status.Middle;
}
/**
* Process the surface release event.
*
* @param xvel xVelocity
* @param yvel yVelocity
* @param isCloseBeforeDragged the open state before drag
*/
protected void processHandRelease(float xvel, float yvel, boolean isCloseBeforeDragged) {
float minVelocity = mDragHelper.getMinVelocity();
View surfaceView = getSurfaceView();
DragEdge currentDragEdge = mCurrentDragEdge;
if (currentDragEdge == null || surfaceView == null) {
return;
}
float willOpenPercent = (isCloseBeforeDragged ? mWillOpenPercentAfterClose : mWillOpenPercentAfterOpen);
if (currentDragEdge == DragEdge.Left) {
if (xvel > minVelocity) open();
else if (xvel < -minVelocity) close();
else {
float openPercent = 1f * getSurfaceView().getLeft() / mDragDistance;
if (openPercent > willOpenPercent) open();
else close();
}
} else if (currentDragEdge == DragEdge.Right) {
if (xvel > minVelocity) close();
else if (xvel < -minVelocity) open();
else {
float openPercent = 1f * (-getSurfaceView().getLeft()) / mDragDistance;
if (openPercent > willOpenPercent) open();
else close();
}
} else if (currentDragEdge == DragEdge.Top) {
if (yvel > minVelocity) open();
else if (yvel < -minVelocity) close();
else {
float openPercent = 1f * getSurfaceView().getTop() / mDragDistance;
if (openPercent > willOpenPercent) open();
else close();
}
} else if (currentDragEdge == DragEdge.Bottom) {
if (yvel > minVelocity) close();
else if (yvel < -minVelocity) open();
else {
float openPercent = 1f * (-getSurfaceView().getTop()) / mDragDistance;
if (openPercent > willOpenPercent) open();
else close();
}
}
}
/**
* smoothly open surface.
*/
public void open() {
open(true, true);
}
public void open(boolean smooth) {
open(smooth, true);
}
public void open(boolean smooth, boolean notify) {
View surface = getSurfaceView(), bottom = getCurrentBottomView();
if (surface == null) {
return;
}
int dx, dy;
Rect rect = computeSurfaceLayoutArea(true);
if (smooth) {
mDragHelper.smoothSlideViewTo(surface, rect.left, rect.top);
} else {
dx = rect.left - surface.getLeft();
dy = rect.top - surface.getTop();
surface.layout(rect.left, rect.top, rect.right, rect.bottom);
if (getShowMode() == ShowMode.PullOut) {
Rect bRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, rect);
if (bottom != null) {
bottom.layout(bRect.left, bRect.top, bRect.right, bRect.bottom);
}
}
if (notify) {
dispatchRevealEvent(rect.left, rect.top, rect.right, rect.bottom);
dispatchSwipeEvent(rect.left, rect.top, dx, dy);
} else {
safeBottomView();
}
}
invalidate();
}
public void open(DragEdge edge) {
setCurrentDragEdge(edge);
open(true, true);
}
public void open(boolean smooth, DragEdge edge) {
setCurrentDragEdge(edge);
open(smooth, true);
}
public void open(boolean smooth, boolean notify, DragEdge edge) {
setCurrentDragEdge(edge);
open(smooth, notify);
}
/**
* smoothly close surface.
*/
public void close() {
close(true, true);
}
public void close(boolean smooth) {
close(smooth, true);
}
/**
* close surface
*
* @param smooth smoothly or not.
* @param notify if notify all the listeners.
*/
public void close(boolean smooth, boolean notify) {
View surface = getSurfaceView();
if (surface == null) {
return;
}
int dx, dy;
if (smooth)
mDragHelper.smoothSlideViewTo(getSurfaceView(), getPaddingLeft(), getPaddingTop());
else {
Rect rect = computeSurfaceLayoutArea(false);
dx = rect.left - surface.getLeft();
dy = rect.top - surface.getTop();
surface.layout(rect.left, rect.top, rect.right, rect.bottom);
if (notify) {
dispatchRevealEvent(rect.left, rect.top, rect.right, rect.bottom);
dispatchSwipeEvent(rect.left, rect.top, dx, dy);
} else {
safeBottomView();
}
}
invalidate();
}
public void toggle() {
toggle(true);
}
public void toggle(boolean smooth) {
if (getOpenStatus() == Status.Open)
close(smooth);
else if (getOpenStatus() == Status.Close) open(smooth);
}
/**
* a helper function to compute the Rect area that surface will hold in.
*
* @param open open status or close status.
*/
private Rect computeSurfaceLayoutArea(boolean open) {
int l = getPaddingLeft(), t = getPaddingTop();
if (open) {
if (mCurrentDragEdge == DragEdge.Left)
l = getPaddingLeft() + mDragDistance;
else if (mCurrentDragEdge == DragEdge.Right)
l = getPaddingLeft() - mDragDistance;
else if (mCurrentDragEdge == DragEdge.Top)
t = getPaddingTop() + mDragDistance;
else t = getPaddingTop() - mDragDistance;
}
return new Rect(l, t, l + getMeasuredWidth(), t + getMeasuredHeight());
}
private Rect computeBottomLayoutAreaViaSurface(ShowMode mode, Rect surfaceArea) {
Rect rect = surfaceArea;
View bottomView = getCurrentBottomView();
int bl = rect.left, bt = rect.top, br = rect.right, bb = rect.bottom;
if (mode == ShowMode.PullOut) {
if (mCurrentDragEdge == DragEdge.Left)
bl = rect.left - mDragDistance;
else if (mCurrentDragEdge == DragEdge.Right)
bl = rect.right;
else if (mCurrentDragEdge == DragEdge.Top)
bt = rect.top - mDragDistance;
else bt = rect.bottom;
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
bb = rect.bottom;
br = bl + (bottomView == null ? 0 : bottomView.getMeasuredWidth());
} else {
bb = bt + (bottomView == null ? 0 : bottomView.getMeasuredHeight());
br = rect.right;
}
} else if (mode == ShowMode.LayDown) {
if (mCurrentDragEdge == DragEdge.Left)
br = bl + mDragDistance;
else if (mCurrentDragEdge == DragEdge.Right)
bl = br - mDragDistance;
else if (mCurrentDragEdge == DragEdge.Top)
bb = bt + mDragDistance;
else bt = bb - mDragDistance;
}
return new Rect(bl, bt, br, bb);
}
private Rect computeBottomLayDown(DragEdge dragEdge) {
int bl = getPaddingLeft(), bt = getPaddingTop();
int br, bb;
if (dragEdge == DragEdge.Right) {
bl = getMeasuredWidth() - mDragDistance;
} else if (dragEdge == DragEdge.Bottom) {
bt = getMeasuredHeight() - mDragDistance;
}
if (dragEdge == DragEdge.Left || dragEdge == DragEdge.Right) {
br = bl + mDragDistance;
bb = bt + getMeasuredHeight();
} else {
br = bl + getMeasuredWidth();
bb = bt + mDragDistance;
}
return new Rect(bl, bt, br, bb);
}
public void setOnDoubleClickListener(DoubleClickListener doubleClickListener) {
mDoubleClickListener = doubleClickListener;
}
public interface DoubleClickListener {
void onDoubleClick(SwipeLayout layout, boolean surface);
}
private int dp2px(float dp) {
return (int) (dp * getContext().getResources().getDisplayMetrics().density + 0.5f);
}
/**
* Deprecated, use {@link #setDrag(DragEdge, View)}
*/
@Deprecated
public void setDragEdge(DragEdge dragEdge) {
clearDragEdge();
if (getChildCount() >= 2) {
mDragEdges.put(dragEdge, getChildAt(getChildCount() - 2));
}
setCurrentDragEdge(dragEdge);
}
public void onViewRemoved(View child) {
for (Map.Entry<DragEdge, View> entry : new HashMap<DragEdge, View>(mDragEdges).entrySet()) {
if (entry.getValue() == child) {
mDragEdges.remove(entry.getKey());
}
}
}
public Map<DragEdge, View> getDragEdgeMap() {
return mDragEdges;
}
/**
* Deprecated, use {@link #getDragEdgeMap()}
*/
@Deprecated
public List<DragEdge> getDragEdges() {
return new ArrayList<DragEdge>(mDragEdges.keySet());
}
/**
* Deprecated, use {@link #setDrag(DragEdge, View)}
*/
@Deprecated
public void setDragEdges(List<DragEdge> dragEdges) {
clearDragEdge();
for (int i = 0, size = Math.min(dragEdges.size(), getChildCount() - 1); i < size; i++) {
DragEdge dragEdge = dragEdges.get(i);
mDragEdges.put(dragEdge, getChildAt(i));
}
if (dragEdges.size() == 0 || dragEdges.contains(DefaultDragEdge)) {
setCurrentDragEdge(DefaultDragEdge);
} else {
setCurrentDragEdge(dragEdges.get(0));
}
}
/**
* Deprecated, use {@link #addDrag(DragEdge, View)}
*/
@Deprecated
public void setDragEdges(DragEdge... mDragEdges) {
clearDragEdge();
setDragEdges(Arrays.asList(mDragEdges));
}
/**
* Deprecated, use {@link #addDrag(DragEdge, View)}
* 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)
*/
@Deprecated
public void setBottomViewIds(int leftId, int rightId, int topId, int bottomId) {
addDrag(DragEdge.Left, findViewById(leftId));
addDrag(DragEdge.Right, findViewById(rightId));
addDrag(DragEdge.Top, findViewById(topId));
addDrag(DragEdge.Bottom, findViewById(bottomId));
}
private float getCurrentOffset() {
if (mCurrentDragEdge == null) return 0;
return mEdgeSwipesOffset[mCurrentDragEdge.ordinal()];
}
private void setCurrentDragEdge(DragEdge dragEdge) {
mCurrentDragEdge = dragEdge;
updateBottomViews();
}
private void updateBottomViews() {
View currentBottomView = getCurrentBottomView();
if (currentBottomView != null) {
if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
mDragDistance = currentBottomView.getMeasuredWidth() - dp2px(getCurrentOffset());
} else {
mDragDistance = currentBottomView.getMeasuredHeight() - dp2px(getCurrentOffset());
}
}
if (mShowMode == ShowMode.PullOut) {
layoutPullOut();
} else if (mShowMode == ShowMode.LayDown) {
layoutLayDown();
}
safeBottomView();
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/adapters/ArraySwipeAdapter.java
================================================
package com.daimajia.swipe.adapters;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public abstract class ArraySwipeAdapter<T> extends ArrayAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
{}
public ArraySwipeAdapter(Context context, int resource) {
super(context, resource);
}
public ArraySwipeAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
}
public ArraySwipeAdapter(Context context, int resource, T[] objects) {
super(context, resource, objects);
}
public ArraySwipeAdapter(Context context, int resource, int textViewResourceId, T[] objects) {
super(context, resource, textViewResourceId, objects);
}
public ArraySwipeAdapter(Context context, int resource, List<T> objects) {
super(context, resource, objects);
}
public ArraySwipeAdapter(Context context, int resource, int textViewResourceId, List<T> objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public void notifyDatasetChanged() {
super.notifyDataSetChanged();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
mItemManger.bind(v, position);
return v;
}
@Override
public void openItem(int position) {
mItemManger.openItem(position);
}
@Override
public void closeItem(int position) {
mItemManger.closeItem(position);
}
@Override
public void closeAllExcept(SwipeLayout layout) {
mItemManger.closeAllExcept(layout);
}
@Override
public void closeAllItems() {
mItemManger.closeAllItems();
}
@Override
public List<Integer> getOpenItems() {
return mItemManger.getOpenItems();
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return mItemManger.getOpenLayouts();
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mItemManger.removeShownLayouts(layout);
}
@Override
public boolean isOpen(int position) {
return mItemManger.isOpen(position);
}
@Override
public Attributes.Mode getMode() {
return mItemManger.getMode();
}
@Override
public void setMode(Attributes.Mode mode) {
mItemManger.setMode(mode);
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/adapters/BaseSwipeAdapter.java
================================================
package com.daimajia.swipe.adapters;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public abstract class BaseSwipeAdapter extends BaseAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
protected SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
/**
* 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.
* Never bind SwipeListener or fill values here, every item has a chance to fill value or bind
* listeners in fillValues.
* to fill it in {@code fillValues} method.
* @param position
* @param parent
* @return
*/
public abstract View generateView(int position, ViewGroup parent);
/**
* fill values or bind listeners to the view.
* @param position
* @param convertView
*/
public abstract void fillValues(int position, View convertView);
@Override
public void notifyDatasetChanged() {
super.notifyDataSetChanged();
}
@Override
public final View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null){
v = generateView(position, parent);
}
mItemManger.bind(v, position);
fillValues(position, v);
return v;
}
@Override
public void openItem(int position) {
mItemManger.openItem(position);
}
@Override
public void closeItem(int position) {
mItemManger.closeItem(position);
}
@Override
public void closeAllExcept(SwipeLayout layout) {
mItemManger.closeAllExcept(layout);
}
@Override
public void closeAllItems() {
mItemManger.closeAllItems();
}
@Override
public List<Integer> getOpenItems() {
return mItemManger.getOpenItems();
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return mItemManger.getOpenLayouts();
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mItemManger.removeShownLayouts(layout);
}
@Override
public boolean isOpen(int position) {
return mItemManger.isOpen(position);
}
@Override
public Attributes.Mode getMode() {
return mItemManger.getMode();
}
@Override
public void setMode(Attributes.Mode mode) {
mItemManger.setMode(mode);
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java
================================================
package com.daimajia.swipe.adapters;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public abstract class CursorSwipeAdapter extends CursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
protected CursorSwipeAdapter(Context context, Cursor c, boolean autoRequery) {
super(context, c, autoRequery);
}
protected CursorSwipeAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
mItemManger.bind(v, position);
return v;
}
@Override
public void openItem(int position) {
mItemManger.openItem(position);
}
@Override
public void closeItem(int position) {
mItemManger.closeItem(position);
}
@Override
public void closeAllExcept(SwipeLayout layout) {
mItemManger.closeAllExcept(layout);
}
@Override
public void closeAllItems() {
mItemManger.closeAllItems();
}
@Override
public List<Integer> getOpenItems() {
return mItemManger.getOpenItems();
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return mItemManger.getOpenLayouts();
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mItemManger.removeShownLayouts(layout);
}
@Override
public boolean isOpen(int position) {
return mItemManger.isOpen(position);
}
@Override
public Attributes.Mode getMode() {
return mItemManger.getMode();
}
@Override
public void setMode(Attributes.Mode mode) {
mItemManger.setMode(mode);
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java
================================================
package com.daimajia.swipe.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public abstract class RecyclerSwipeAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements SwipeItemMangerInterface, SwipeAdapterInterface {
public SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
@Override
public abstract VH onCreateViewHolder(ViewGroup parent, int viewType);
@Override
public abstract void onBindViewHolder(VH viewHolder, final int position);
@Override
public void notifyDatasetChanged() {
super.notifyDataSetChanged();
}
@Override
public void openItem(int position) {
mItemManger.openItem(position);
}
@Override
public void closeItem(int position) {
mItemManger.closeItem(position);
}
@Override
public void closeAllExcept(SwipeLayout layout) {
mItemManger.closeAllExcept(layout);
}
@Override
public void closeAllItems() {
mItemManger.closeAllItems();
}
@Override
public List<Integer> getOpenItems() {
return mItemManger.getOpenItems();
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return mItemManger.getOpenLayouts();
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mItemManger.removeShownLayouts(layout);
}
@Override
public boolean isOpen(int position) {
return mItemManger.isOpen(position);
}
@Override
public Attributes.Mode getMode() {
return mItemManger.getMode();
}
@Override
public void setMode(Attributes.Mode mode) {
mItemManger.setMode(mode);
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java
================================================
package com.daimajia.swipe.adapters;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapter implements SwipeItemMangerInterface, SwipeAdapterInterface {
private SwipeItemMangerImpl mItemManger = new SwipeItemMangerImpl(this);
protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
}
protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
mItemManger.bind(v, position);
return v;
}
@Override
public void openItem(int position) {
mItemManger.openItem(position);
}
@Override
public void closeItem(int position) {
mItemManger.closeItem(position);
}
@Override
public void closeAllExcept(SwipeLayout layout) {
mItemManger.closeAllExcept(layout);
}
@Override
public List<Integer> getOpenItems() {
return mItemManger.getOpenItems();
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return mItemManger.getOpenLayouts();
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mItemManger.removeShownLayouts(layout);
}
@Override
public boolean isOpen(int position) {
return mItemManger.isOpen(position);
}
@Override
public Attributes.Mode getMode() {
return mItemManger.getMode();
}
@Override
public void setMode(Attributes.Mode mode) {
mItemManger.setMode(mode);
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/implments/SwipeItemMangerImpl.java
================================================
package com.daimajia.swipe.implments;
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.Collections;
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 SwipeItemMangerImpl implements SwipeItemMangerInterface {
private Attributes.Mode mode = Attributes.Mode.Single;
public final int INVALID_POSITION = -1;
protected int mOpenPosition = INVALID_POSITION;
protected Set<Integer> mOpenPositions = new HashSet<Integer>();
protected Set<SwipeLayout> mShownLayouts = new HashSet<SwipeLayout>();
protected SwipeAdapterInterface swipeAdapterInterface;
public SwipeItemMangerImpl(SwipeAdapterInterface swipeAdapterInterface) {
if (swipeAdapterInterface == null)
throw new IllegalArgumentException("SwipeAdapterInterface can not be null");
this.swipeAdapterInterface = swipeAdapterInterface;
}
public Attributes.Mode getMode() {
return mode;
}
public void setMode(Attributes.Mode mode) {
this.mode = mode;
mOpenPositions.clear();
mShownLayouts.clear();
mOpenPosition = INVALID_POSITION;
}
public void bind(View view, 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");
if (swipeLayout.getTag(resId) == null) {
OnLayoutListener onLayoutListener = new OnLayoutListener(position);
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 openItem(int position) {
if (mode == Attributes.Mode.Multiple) {
if (!mOpenPositions.contains(position))
mOpenPositions.add(position);
} else {
mOpenPosition = position;
}
swipeAdapterInterface.notifyDatasetChanged();
}
@Override
public void closeItem(int position) {
if (mode == Attributes.Mode.Multiple) {
mOpenPositions.remove(position);
} else {
if (mOpenPosition == position)
mOpenPosition = INVALID_POSITION;
}
swipeAdapterInterface.notifyDatasetChanged();
}
@Override
public void closeAllExcept(SwipeLayout layout) {
for (SwipeLayout s : mShownLayouts) {
if (s != layout)
s.close();
}
}
@Override
public void closeAllItems() {
if (mode == Attributes.Mode.Multiple) {
mOpenPositions.clear();
} else {
mOpenPosition = INVALID_POSITION;
}
for (SwipeLayout s : mShownLayouts) {
s.close();
}
}
@Override
public void removeShownLayouts(SwipeLayout layout) {
mShownLayouts.remove(layout);
}
@Override
public List<Integer> getOpenItems() {
if (mode == Attributes.Mode.Multiple) {
return new ArrayList<Integer>(mOpenPositions);
} else {
return Collections.singletonList(mOpenPosition);
}
}
@Override
public List<SwipeLayout> getOpenLayouts() {
return new ArrayList<SwipeLayout>(mShownLayouts);
}
@Override
public boolean isOpen(int position) {
if (mode == Attributes.Mode.Multiple) {
return mOpenPositions.contains(position);
} else {
return mOpenPosition == position;
}
}
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) {
if (isOpen(position)) {
v.open(false, false);
} else {
v.close(false, false);
}
}
}
class SwipeMemory extends SimpleSwipeListener {
private int position;
SwipeMemory(int position) {
this.position = position;
}
@Override
public void onClose(SwipeLayout layout) {
if (mode == Attributes.Mode.Multiple) {
mOpenPositions.remove(position);
} else {
mOpenPosition = INVALID_POSITION;
}
}
@Override
public void onStartOpen(SwipeLayout layout) {
if (mode == Attributes.Mode.Single) {
closeAllExcept(layout);
}
}
@Override
public void onOpen(SwipeLayout layout) {
if (mode == Attributes.Mode.Multiple)
mOpenPositions.add(position);
else {
closeAllExcept(layout);
mOpenPosition = position;
}
}
public void setPosition(int position) {
this.position = position;
}
}
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/interfaces/SwipeAdapterInterface.java
================================================
package com.daimajia.swipe.interfaces;
public interface SwipeAdapterInterface {
int getSwipeLayoutResourceId(int position);
void notifyDatasetChanged();
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/interfaces/SwipeItemMangerInterface.java
================================================
package com.daimajia.swipe.interfaces;
import com.daimajia.swipe.SwipeLayout;
import com.daimajia.swipe.util.Attributes;
import java.util.List;
public interface SwipeItemMangerInterface {
void openItem(int position);
void closeItem(int position);
void closeAllExcept(SwipeLayout layout);
void closeAllItems();
List<Integer> getOpenItems();
List<SwipeLayout> getOpenLayouts();
void removeShownLayouts(SwipeLayout layout);
boolean isOpen(int position);
Attributes.Mode getMode();
void setMode(Attributes.Mode mode);
}
================================================
FILE: library/src/main/java/com/daimajia/swipe/util/Attributes.java
================================================
package com.daimajia.swipe.util;
public class Attributes {
public enum Mode {
Single, Multiple
}
}
================================================
FILE: library/src/main/res/values/attrs.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeLayout">
<attr name="drag_edge">
<flag name="left" value="1" />
<flag name="right" value="2" />
<flag name="top" value="4" />
<flag name="bottom" value="8" />
</attr>
<attr name="leftEdgeSwipeOffset" format="dimension" />
<attr name="rightEdgeSwipeOffset" format="dimension" />
<attr name="topEdgeSwipeOffset" format="dimension" />
<attr name="bottomEdgeSwipeOffset" format="dimension" />
<attr name="show_mode" format="enum">
<enum name="lay_down" value="0" />
<enum name="pull_out" value="1" />
</attr>
<attr name="clickToClose" format="boolean" />
</declare-styleable>
</resources>
================================================
FILE: settings.gradle
================================================
include ':demo', ':library'
gitextract_y9qg2upq/ ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── demo/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── daimajia/ │ │ └── swipedemo/ │ │ ├── GridViewExample.java │ │ ├── ListViewExample.java │ │ ├── MyActivity.java │ │ ├── NestedExample.java │ │ ├── RecyclerViewExample.java │ │ └── adapter/ │ │ ├── ArraySwipeAdapterSample.java │ │ ├── GridViewAdapter.java │ │ ├── ListViewAdapter.java │ │ ├── RecyclerViewAdapter.java │ │ └── util/ │ │ ├── DividerItemDecoration.java │ │ └── RecyclerItemClickListener.java │ └── res/ │ ├── drawable/ │ │ ├── dark_gray.xml │ │ ├── divider.xml │ │ ├── item_selector.xml │ │ ├── red.xml │ │ └── white.xml │ ├── layout/ │ │ ├── complicate_layout.xml │ │ ├── grid_item.xml │ │ ├── gridview.xml │ │ ├── listview.xml │ │ ├── listview_item.xml │ │ ├── main.xml │ │ ├── recyclerview.xml │ │ ├── recyclerview_item.xml │ │ ├── sampe_nested_edittext.xml │ │ ├── sampe_nested_scrollview.xml │ │ ├── sampe_nested_seekbar.xml │ │ ├── sample1.xml │ │ ├── sample2.xml │ │ ├── sample3.xml │ │ ├── sample_nested_parent.xml │ │ └── sample_together.xml │ ├── menu/ │ │ └── my.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── values-w820dp/ │ └── dimens.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ ├── gradle-mvn-push.gradle │ ├── gradle.properties │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── daimajia/ │ │ └── swipe/ │ │ ├── SimpleSwipeListener.java │ │ ├── SwipeLayout.java │ │ ├── adapters/ │ │ │ ├── ArraySwipeAdapter.java │ │ │ ├── BaseSwipeAdapter.java │ │ │ ├── CursorSwipeAdapter.java │ │ │ ├── RecyclerSwipeAdapter.java │ │ │ └── SimpleCursorSwipeAdapter.java │ │ ├── implments/ │ │ │ └── SwipeItemMangerImpl.java │ │ ├── interfaces/ │ │ │ ├── SwipeAdapterInterface.java │ │ │ └── SwipeItemMangerInterface.java │ │ └── util/ │ │ └── Attributes.java │ └── res/ │ └── values/ │ └── attrs.xml └── settings.gradle
SYMBOL INDEX (316 symbols across 22 files)
FILE: demo/src/main/java/com/daimajia/swipedemo/GridViewExample.java
class GridViewExample (line 13) | public class GridViewExample extends Activity{
method onCreate (line 15) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/ListViewExample.java
class ListViewExample (line 23) | public class ListViewExample extends Activity {
method onCreate (line 29) | @Override
method onCreateOptionsMenu (line 100) | @Override
method onOptionsItemSelected (line 107) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/MyActivity.java
class MyActivity (line 16) | public class MyActivity extends Activity {
method onCreate (line 20) | @Override
method onCreateOptionsMenu (line 162) | @Override
method onOptionsItemSelected (line 169) | @Override
method evaluate (line 193) | public Object evaluate(float fraction, Object startValue, Object endVa...
FILE: demo/src/main/java/com/daimajia/swipedemo/NestedExample.java
class NestedExample (line 10) | public class NestedExample extends Activity{
method onCreate (line 12) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java
class RecyclerViewExample (line 23) | public class RecyclerViewExample extends Activity {
method onCreate (line 39) | @Override
method onScrollStateChanged (line 73) | @Override
method onScrolled (line 79) | @Override
method onCreateOptionsMenu (line 87) | @Override
method onOptionsItemSelected (line 94) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/ArraySwipeAdapterSample.java
class ArraySwipeAdapterSample (line 14) | public class ArraySwipeAdapterSample<T> extends ArraySwipeAdapter {
method ArraySwipeAdapterSample (line 15) | public ArraySwipeAdapterSample(Context context, int resource) {
method ArraySwipeAdapterSample (line 19) | public ArraySwipeAdapterSample(Context context, int resource, int text...
method ArraySwipeAdapterSample (line 23) | public ArraySwipeAdapterSample(Context context, int resource, Object[]...
method ArraySwipeAdapterSample (line 27) | public ArraySwipeAdapterSample(Context context, int resource, int text...
method ArraySwipeAdapterSample (line 31) | public ArraySwipeAdapterSample(Context context, int resource, List obj...
method ArraySwipeAdapterSample (line 35) | public ArraySwipeAdapterSample(Context context, int resource, int text...
method getSwipeLayoutResourceId (line 39) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/GridViewAdapter.java
class GridViewAdapter (line 12) | public class GridViewAdapter extends BaseSwipeAdapter {
method GridViewAdapter (line 16) | public GridViewAdapter(Context mContext) {
method getSwipeLayoutResourceId (line 20) | @Override
method generateView (line 25) | @Override
method fillValues (line 30) | @Override
method getCount (line 36) | @Override
method getItem (line 41) | @Override
method getItemId (line 46) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/ListViewAdapter.java
class ListViewAdapter (line 17) | public class ListViewAdapter extends BaseSwipeAdapter {
method ListViewAdapter (line 21) | public ListViewAdapter(Context mContext) {
method getSwipeLayoutResourceId (line 25) | @Override
method generateView (line 30) | @Override
method fillValues (line 55) | @Override
method getCount (line 61) | @Override
method getItem (line 66) | @Override
method getItemId (line 71) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java
class RecyclerViewAdapter (line 22) | public class RecyclerViewAdapter extends RecyclerSwipeAdapter<RecyclerVi...
class SimpleViewHolder (line 24) | public static class SimpleViewHolder extends RecyclerView.ViewHolder {
method SimpleViewHolder (line 30) | public SimpleViewHolder(View itemView) {
method RecyclerViewAdapter (line 52) | public RecyclerViewAdapter(Context context, ArrayList<String> objects) {
method onCreateViewHolder (line 57) | @Override
method onBindViewHolder (line 63) | @Override
method getItemCount (line 95) | @Override
method getSwipeLayoutResourceId (line 100) | @Override
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java
class DividerItemDecoration (line 13) | public class DividerItemDecoration extends RecyclerView.ItemDecoration {
method DividerItemDecoration (line 20) | public DividerItemDecoration(Context context, AttributeSet attrs) {
method DividerItemDecoration (line 27) | public DividerItemDecoration(Context context, AttributeSet attrs, bool...
method DividerItemDecoration (line 34) | public DividerItemDecoration(Drawable divider) {
method DividerItemDecoration (line 38) | public DividerItemDecoration(Drawable divider, boolean showFirstDivider,
method getItemOffsets (line 45) | @Override
method onDrawOver (line 63) | @Override
method getOrientation (line 116) | private int getOrientation(RecyclerView parent) {
FILE: demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java
class RecyclerItemClickListener (line 9) | public class RecyclerItemClickListener implements RecyclerView.OnItemTou...
type OnItemClickListener (line 12) | public interface OnItemClickListener {
method onItemClick (line 13) | public void onItemClick(View view, int position);
method RecyclerItemClickListener (line 18) | public RecyclerItemClickListener(Context context, OnItemClickListener ...
method onInterceptTouchEvent (line 28) | @Override
method onTouchEvent (line 37) | @Override
method onRequestDisallowInterceptTouchEvent (line 41) | @Override
FILE: library/src/main/java/com/daimajia/swipe/SimpleSwipeListener.java
class SimpleSwipeListener (line 3) | public class SimpleSwipeListener implements SwipeLayout.SwipeListener {
method onStartOpen (line 5) | @Override
method onOpen (line 9) | @Override
method onStartClose (line 13) | @Override
method onClose (line 17) | @Override
method onUpdate (line 21) | @Override
method onHandRelease (line 25) | @Override
FILE: library/src/main/java/com/daimajia/swipe/SwipeLayout.java
class SwipeLayout (line 30) | public class SwipeLayout extends FrameLayout {
type DragEdge (line 64) | public enum DragEdge {
type ShowMode (line 71) | public enum ShowMode {
method SwipeLayout (line 76) | public SwipeLayout(Context context) {
method SwipeLayout (line 80) | public SwipeLayout(Context context, AttributeSet attrs) {
method SwipeLayout (line 84) | public SwipeLayout(Context context, AttributeSet attrs, int defStyle) {
type SwipeListener (line 115) | public interface SwipeListener {
method onStartOpen (line 116) | void onStartOpen(SwipeLayout layout);
method onOpen (line 118) | void onOpen(SwipeLayout layout);
method onStartClose (line 120) | void onStartClose(SwipeLayout layout);
method onClose (line 122) | void onClose(SwipeLayout layout);
method onUpdate (line 124) | void onUpdate(SwipeLayout layout, int leftOffset, int topOffset);
method onHandRelease (line 126) | void onHandRelease(SwipeLayout layout, float xvel, float yvel);
method addSwipeListener (line 129) | public void addSwipeListener(SwipeListener l) {
method removeSwipeListener (line 133) | public void removeSwipeListener(SwipeListener l) {
method removeAllSwipeListener (line 137) | public void removeAllSwipeListener() {
type SwipeDenier (line 141) | public interface SwipeDenier {
method shouldDenySwipe (line 149) | boolean shouldDenySwipe(MotionEvent ev);
method addSwipeDenier (line 152) | public void addSwipeDenier(SwipeDenier denier) {
method removeSwipeDenier (line 156) | public void removeSwipeDenier(SwipeDenier denier) {
method removeAllSwipeDeniers (line 160) | public void removeAllSwipeDeniers() {
type OnRevealListener (line 164) | public interface OnRevealListener {
method onReveal (line 165) | void onReveal(View child, DragEdge edge, float fraction, int distance);
method addRevealListener (line 176) | public void addRevealListener(int childId, OnRevealListener l) {
method addRevealListener (line 198) | public void addRevealListener(int[] childIds, OnRevealListener l) {
method removeRevealListener (line 203) | public void removeRevealListener(int childId, OnRevealListener l) {
method removeAllRevealListeners (line 212) | public void removeAllRevealListeners(int childId) {
method clampViewPositionHorizontal (line 222) | @Override
method clampViewPositionVertical (line 263) | @Override
method tryCaptureView (line 315) | @Override
method getViewHorizontalDragRange (line 324) | @Override
method getViewVerticalDragRange (line 329) | @Override
method onViewReleased (line 336) | @Override
method onViewPositionChanged (line 347) | @Override
method captureChildrenBound (line 405) | private void captureChildrenBound() {
method isViewTotallyFirstShowed (line 431) | protected boolean isViewTotallyFirstShowed(View child, Rect relativePo...
method isViewShowing (line 453) | protected boolean isViewShowing(View child, Rect relativePosition, Dra...
method getRelativePosition (line 501) | protected Rect getRelativePosition(View child) {
method dispatchSwipeEvent (line 517) | protected void dispatchSwipeEvent(int surfaceLeft, int surfaceTop, int...
method dispatchSwipeEvent (line 533) | protected void dispatchSwipeEvent(int surfaceLeft, int surfaceTop, boo...
method safeBottomView (line 573) | private void safeBottomView() {
method dispatchRevealEvent (line 591) | protected void dispatchRevealEvent(final int surfaceLeft, final int su...
method computeScroll (line 665) | @Override
type OnLayout (line 677) | public interface OnLayout {
method onLayout (line 678) | void onLayout(SwipeLayout v);
method addOnLayoutListener (line 683) | public void addOnLayoutListener(OnLayout l) {
method removeOnLayoutListener (line 688) | public void removeOnLayoutListener(OnLayout l) {
method clearDragEdge (line 692) | public void clearDragEdge() {
method setDrag (line 696) | public void setDrag(DragEdge dragEdge, int childId) {
method setDrag (line 701) | public void setDrag(DragEdge dragEdge, View child) {
method addDrag (line 706) | public void addDrag(DragEdge dragEdge, int childId) {
method addDrag (line 710) | public void addDrag(DragEdge dragEdge, View child) {
method addDrag (line 714) | public void addDrag(DragEdge dragEdge, View child, ViewGroup.LayoutPar...
method addView (line 744) | @Override
method onLayout (line 784) | @Override
method layoutPullOut (line 793) | void layoutPullOut() {
method layoutLayDown (line 810) | void layoutLayDown() {
method checkCanDrag (line 829) | private void checkCanDrag(MotionEvent ev) {
method onInterceptTouchEvent (line 902) | @Override
method onTouchEvent (line 956) | @Override
method isClickToClose (line 992) | public boolean isClickToClose() {
method setClickToClose (line 996) | public void setClickToClose(boolean mClickToClose) {
method setSwipeEnabled (line 1000) | public void setSwipeEnabled(boolean enabled) {
method isSwipeEnabled (line 1004) | public boolean isSwipeEnabled() {
method isLeftSwipeEnabled (line 1008) | public boolean isLeftSwipeEnabled() {
method setLeftSwipeEnabled (line 1014) | public void setLeftSwipeEnabled(boolean leftSwipeEnabled) {
method isRightSwipeEnabled (line 1018) | public boolean isRightSwipeEnabled() {
method setRightSwipeEnabled (line 1024) | public void setRightSwipeEnabled(boolean rightSwipeEnabled) {
method isTopSwipeEnabled (line 1028) | public boolean isTopSwipeEnabled() {
method setTopSwipeEnabled (line 1034) | public void setTopSwipeEnabled(boolean topSwipeEnabled) {
method isBottomSwipeEnabled (line 1038) | public boolean isBottomSwipeEnabled() {
method setBottomSwipeEnabled (line 1044) | public void setBottomSwipeEnabled(boolean bottomSwipeEnabled) {
method getWillOpenPercentAfterOpen (line 1054) | public float getWillOpenPercentAfterOpen() {
method setWillOpenPercentAfterOpen (line 1064) | public void setWillOpenPercentAfterOpen(float willOpenPercentAfterOpen) {
method getWillOpenPercentAfterClose (line 1074) | public float getWillOpenPercentAfterClose() {
method setWillOpenPercentAfterClose (line 1084) | public void setWillOpenPercentAfterClose(float willOpenPercentAfterClo...
method insideAdapterView (line 1088) | private boolean insideAdapterView() {
method getAdapterView (line 1092) | private AdapterView getAdapterView() {
method performAdapterViewItemClick (line 1100) | private void performAdapterViewItemClick() {
method performAdapterViewItemLongClick (line 1113) | private boolean performAdapterViewItemLongClick() {
method onAttachedToWindow (line 1142) | @Override
method setOnClickListener (line 1168) | @Override
method setOnLongClickListener (line 1176) | @Override
method isTouchOnSurface (line 1184) | private boolean isTouchOnSurface(MotionEvent ev) {
class SwipeDetector (line 1198) | class SwipeDetector extends GestureDetector.SimpleOnGestureListener {
method onSingleTapUp (line 1199) | @Override
method onDoubleTap (line 1207) | @Override
method setDragDistance (line 1231) | public void setDragDistance(int max) {
method setShowMode (line 1244) | public void setShowMode(ShowMode mode) {
method getDragEdge (line 1249) | public DragEdge getDragEdge() {
method getDragDistance (line 1253) | public int getDragDistance() {
method getShowMode (line 1257) | public ShowMode getShowMode() {
method getSurfaceView (line 1264) | public View getSurfaceView() {
method getCurrentBottomView (line 1272) | public View getCurrentBottomView() {
method getBottomViews (line 1283) | public List<View> getBottomViews() {
type Status (line 1291) | public enum Status {
method getOpenStatus (line 1303) | public Status getOpenStatus() {
method processHandRelease (line 1327) | protected void processHandRelease(float xvel, float yvel, boolean isCl...
method open (line 1373) | public void open() {
method open (line 1377) | public void open(boolean smooth) {
method open (line 1381) | public void open(boolean smooth, boolean notify) {
method open (line 1410) | public void open(DragEdge edge) {
method open (line 1415) | public void open(boolean smooth, DragEdge edge) {
method open (line 1420) | public void open(boolean smooth, boolean notify, DragEdge edge) {
method close (line 1428) | public void close() {
method close (line 1432) | public void close(boolean smooth) {
method close (line 1442) | public void close(boolean smooth, boolean notify) {
method toggle (line 1465) | public void toggle() {
method toggle (line 1469) | public void toggle(boolean smooth) {
method computeSurfaceLayoutArea (line 1481) | private Rect computeSurfaceLayoutArea(boolean open) {
method computeBottomLayoutAreaViaSurface (line 1495) | private Rect computeBottomLayoutAreaViaSurface(ShowMode mode, Rect sur...
method computeBottomLayDown (line 1530) | private Rect computeBottomLayDown(DragEdge dragEdge) {
method setOnDoubleClickListener (line 1548) | public void setOnDoubleClickListener(DoubleClickListener doubleClickLi...
type DoubleClickListener (line 1552) | public interface DoubleClickListener {
method onDoubleClick (line 1553) | void onDoubleClick(SwipeLayout layout, boolean surface);
method dp2px (line 1556) | private int dp2px(float dp) {
method setDragEdge (line 1564) | @Deprecated
method onViewRemoved (line 1573) | public void onViewRemoved(View child) {
method getDragEdgeMap (line 1581) | public Map<DragEdge, View> getDragEdgeMap() {
method getDragEdges (line 1588) | @Deprecated
method setDragEdges (line 1596) | @Deprecated
method setDragEdges (line 1613) | @Deprecated
method setBottomViewIds (line 1624) | @Deprecated
method getCurrentOffset (line 1632) | private float getCurrentOffset() {
method setCurrentDragEdge (line 1637) | private void setCurrentDragEdge(DragEdge dragEdge) {
method updateBottomViews (line 1642) | private void updateBottomViews() {
FILE: library/src/main/java/com/daimajia/swipe/adapters/ArraySwipeAdapter.java
class ArraySwipeAdapter (line 16) | public abstract class ArraySwipeAdapter<T> extends ArrayAdapter implemen...
method ArraySwipeAdapter (line 20) | public ArraySwipeAdapter(Context context, int resource) {
method ArraySwipeAdapter (line 24) | public ArraySwipeAdapter(Context context, int resource, int textViewRe...
method ArraySwipeAdapter (line 28) | public ArraySwipeAdapter(Context context, int resource, T[] objects) {
method ArraySwipeAdapter (line 32) | public ArraySwipeAdapter(Context context, int resource, int textViewRe...
method ArraySwipeAdapter (line 36) | public ArraySwipeAdapter(Context context, int resource, List<T> object...
method ArraySwipeAdapter (line 40) | public ArraySwipeAdapter(Context context, int resource, int textViewRe...
method notifyDatasetChanged (line 44) | @Override
method getView (line 49) | @Override
method openItem (line 56) | @Override
method closeItem (line 61) | @Override
method closeAllExcept (line 66) | @Override
method closeAllItems (line 71) | @Override
method getOpenItems (line 76) | @Override
method getOpenLayouts (line 81) | @Override
method removeShownLayouts (line 86) | @Override
method isOpen (line 91) | @Override
method getMode (line 96) | @Override
method setMode (line 101) | @Override
FILE: library/src/main/java/com/daimajia/swipe/adapters/BaseSwipeAdapter.java
class BaseSwipeAdapter (line 15) | public abstract class BaseSwipeAdapter extends BaseAdapter implements Sw...
method getSwipeLayoutResourceId (line 24) | public abstract int getSwipeLayoutResourceId(int position);
method generateView (line 35) | public abstract View generateView(int position, ViewGroup parent);
method fillValues (line 42) | public abstract void fillValues(int position, View convertView);
method notifyDatasetChanged (line 44) | @Override
method getView (line 50) | @Override
method openItem (line 61) | @Override
method closeItem (line 66) | @Override
method closeAllExcept (line 71) | @Override
method closeAllItems (line 76) | @Override
method getOpenItems (line 81) | @Override
method getOpenLayouts (line 86) | @Override
method removeShownLayouts (line 91) | @Override
method isOpen (line 96) | @Override
method getMode (line 101) | @Override
method setMode (line 106) | @Override
FILE: library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java
class CursorSwipeAdapter (line 17) | public abstract class CursorSwipeAdapter extends CursorAdapter implement...
method CursorSwipeAdapter (line 21) | protected CursorSwipeAdapter(Context context, Cursor c, boolean autoRe...
method CursorSwipeAdapter (line 25) | protected CursorSwipeAdapter(Context context, Cursor c, int flags) {
method getView (line 29) | @Override
method openItem (line 36) | @Override
method closeItem (line 41) | @Override
method closeAllExcept (line 46) | @Override
method closeAllItems (line 51) | @Override
method getOpenItems (line 56) | @Override
method getOpenLayouts (line 61) | @Override
method removeShownLayouts (line 66) | @Override
method isOpen (line 71) | @Override
method getMode (line 76) | @Override
method setMode (line 81) | @Override
FILE: library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java
class RecyclerSwipeAdapter (line 14) | public abstract class RecyclerSwipeAdapter<VH extends RecyclerView.ViewH...
method onCreateViewHolder (line 18) | @Override
method onBindViewHolder (line 21) | @Override
method notifyDatasetChanged (line 24) | @Override
method openItem (line 29) | @Override
method closeItem (line 34) | @Override
method closeAllExcept (line 39) | @Override
method closeAllItems (line 44) | @Override
method getOpenItems (line 49) | @Override
method getOpenLayouts (line 54) | @Override
method removeShownLayouts (line 59) | @Override
method isOpen (line 64) | @Override
method getMode (line 69) | @Override
method setMode (line 74) | @Override
FILE: library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java
class SimpleCursorSwipeAdapter (line 17) | public abstract class SimpleCursorSwipeAdapter extends SimpleCursorAdapt...
method SimpleCursorSwipeAdapter (line 21) | protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor...
method SimpleCursorSwipeAdapter (line 25) | protected SimpleCursorSwipeAdapter(Context context, int layout, Cursor...
method getView (line 29) | @Override
method openItem (line 36) | @Override
method closeItem (line 41) | @Override
method closeAllExcept (line 46) | @Override
method getOpenItems (line 51) | @Override
method getOpenLayouts (line 56) | @Override
method removeShownLayouts (line 61) | @Override
method isOpen (line 66) | @Override
method getMode (line 71) | @Override
method setMode (line 76) | @Override
FILE: library/src/main/java/com/daimajia/swipe/implments/SwipeItemMangerImpl.java
class SwipeItemMangerImpl (line 20) | public class SwipeItemMangerImpl implements SwipeItemMangerInterface {
method SwipeItemMangerImpl (line 32) | public SwipeItemMangerImpl(SwipeAdapterInterface swipeAdapterInterface) {
method getMode (line 39) | public Attributes.Mode getMode() {
method setMode (line 43) | public void setMode(Attributes.Mode mode) {
method bind (line 50) | public void bind(View view, int position) {
method openItem (line 71) | @Override
method closeItem (line 82) | @Override
method closeAllExcept (line 93) | @Override
method closeAllItems (line 101) | @Override
method removeShownLayouts (line 113) | @Override
method getOpenItems (line 118) | @Override
method getOpenLayouts (line 127) | @Override
method isOpen (line 132) | @Override
class ValueBox (line 141) | class ValueBox {
method ValueBox (line 146) | ValueBox(int position, SwipeMemory swipeMemory, OnLayoutListener onL...
class OnLayoutListener (line 153) | class OnLayoutListener implements SwipeLayout.OnLayout {
method OnLayoutListener (line 157) | OnLayoutListener(int position) {
method setPosition (line 161) | public void setPosition(int position) {
method onLayout (line 165) | @Override
class SwipeMemory (line 176) | class SwipeMemory extends SimpleSwipeListener {
method SwipeMemory (line 180) | SwipeMemory(int position) {
method onClose (line 184) | @Override
method onStartOpen (line 193) | @Override
method onOpen (line 200) | @Override
method setPosition (line 210) | public void setPosition(int position) {
FILE: library/src/main/java/com/daimajia/swipe/interfaces/SwipeAdapterInterface.java
type SwipeAdapterInterface (line 3) | public interface SwipeAdapterInterface {
method getSwipeLayoutResourceId (line 5) | int getSwipeLayoutResourceId(int position);
method notifyDatasetChanged (line 7) | void notifyDatasetChanged();
FILE: library/src/main/java/com/daimajia/swipe/interfaces/SwipeItemMangerInterface.java
type SwipeItemMangerInterface (line 8) | public interface SwipeItemMangerInterface {
method openItem (line 10) | void openItem(int position);
method closeItem (line 12) | void closeItem(int position);
method closeAllExcept (line 14) | void closeAllExcept(SwipeLayout layout);
method closeAllItems (line 16) | void closeAllItems();
method getOpenItems (line 18) | List<Integer> getOpenItems();
method getOpenLayouts (line 20) | List<SwipeLayout> getOpenLayouts();
method removeShownLayouts (line 22) | void removeShownLayouts(SwipeLayout layout);
method isOpen (line 24) | boolean isOpen(int position);
method getMode (line 26) | Attributes.Mode getMode();
method setMode (line 28) | void setMode(Attributes.Mode mode);
FILE: library/src/main/java/com/daimajia/swipe/util/Attributes.java
class Attributes (line 4) | public class Attributes {
type Mode (line 6) | public enum Mode {
Condensed preview — 71 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (180K chars).
[
{
"path": ".gitignore",
"chars": 464,
"preview": ".gradle\n/local.properties\n/.idea/workspace.xml\n.DS_Store\n/build\n# built application files\n*.apk\n*.ap_\n\n# files for the d"
},
{
"path": ".travis.yml",
"chars": 210,
"preview": "language: android\nandroid:\n components:\n - tools\n - platform-tools\n - build-tools-25.0.2\n - android-25\n - extra-an"
},
{
"path": "LICENSE",
"chars": 1070,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 代码家\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "README.md",
"chars": 3405,
"preview": "# Android Swipe Layout [](https://tr"
},
{
"path": "build.gradle",
"chars": 628,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "demo/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "demo/build.gradle",
"chars": 1134,
"preview": "apply plugin: 'com.android.application'\n\nrepositories {\n jcenter()\n}\n\nandroid {\n compileSdkVersion Integer.parseIn"
},
{
"path": "demo/proguard-rules.pro",
"chars": 667,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /A"
},
{
"path": "demo/src/main/AndroidManifest.xml",
"chars": 1158,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:to"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/GridViewExample.java",
"chars": 1823,
"preview": "package com.daimajia.swipedemo;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.util.Log;\nimport "
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/ListViewExample.java",
"chars": 4991,
"preview": "package com.daimajia.swipedemo;\n\nimport android.app.ActionBar;\nimport android.app.Activity;\nimport android.content.Conte"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/MyActivity.java",
"chars": 8705,
"preview": "package com.daimajia.swipedemo;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.graphics.Col"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/NestedExample.java",
"chars": 1077,
"preview": "package com.daimajia.swipedemo;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.view.View;\nimport"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/RecyclerViewExample.java",
"chars": 4654,
"preview": "package com.daimajia.swipedemo;\n\nimport android.app.ActionBar;\nimport android.app.Activity;\nimport android.content.Inten"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/ArraySwipeAdapterSample.java",
"chars": 1305,
"preview": "package com.daimajia.swipedemo.adapter;\n\nimport android.content.Context;\n\nimport com.daimajia.swipe.adapters.ArraySwipeA"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/GridViewAdapter.java",
"chars": 1165,
"preview": "package com.daimajia.swipedemo.adapter;\n\nimport android.content.Context;\nimport android.view.LayoutInflater;\nimport andr"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/ListViewAdapter.java",
"chars": 2345,
"preview": "package com.daimajia.swipedemo.adapter;\n\nimport android.content.Context;\nimport android.view.LayoutInflater;\nimport andr"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/RecyclerViewAdapter.java",
"chars": 4113,
"preview": "package com.daimajia.swipedemo.adapter;\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerView;\n"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/util/DividerItemDecoration.java",
"chars": 4612,
"preview": "package com.daimajia.swipedemo.adapter.util;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimp"
},
{
"path": "demo/src/main/java/com/daimajia/swipedemo/adapter/util/RecyclerItemClickListener.java",
"chars": 1439,
"preview": "package com.daimajia.swipedemo.adapter.util;\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerV"
},
{
"path": "demo/src/main/res/drawable/dark_gray.xml",
"chars": 336,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <item "
},
{
"path": "demo/src/main/res/drawable/divider.xml",
"chars": 823,
"preview": "<!--\n ~ Copyright (C) 2014 Lucas Rocha\n ~\n ~ Licensed under the Apache License, Version 2.0 (the \"License\");\n ~ you "
},
{
"path": "demo/src/main/res/drawable/item_selector.xml",
"chars": 352,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <item "
},
{
"path": "demo/src/main/res/drawable/red.xml",
"chars": 318,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <item "
},
{
"path": "demo/src/main/res/drawable/white.xml",
"chars": 348,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n <item "
},
{
"path": "demo/src/main/res/layout/complicate_layout.xml",
"chars": 814,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n and"
},
{
"path": "demo/src/main/res/layout/grid_item.xml",
"chars": 1245,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout\n xmlns:android=\"http://schemas.android.com/ap"
},
{
"path": "demo/src/main/res/layout/gridview.xml",
"chars": 400,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<GridView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:"
},
{
"path": "demo/src/main/res/layout/listview.xml",
"chars": 245,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <ListView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
},
{
"path": "demo/src/main/res/layout/listview_item.xml",
"chars": 2106,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<com.daimajia.swipe.SwipeLayout\n xmlns:swipe=\"http://schemas.android.com/apk/"
},
{
"path": "demo/src/main/res/layout/main.xml",
"chars": 1409,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.daimajia.swipe.SwipeLayout\n xmlns:android=\"http://schemas.android.com/apk"
},
{
"path": "demo/src/main/res/layout/recyclerview.xml",
"chars": 350,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- A RecyclerView with some commonly used attributes -->\n<android.support.v7.wi"
},
{
"path": "demo/src/main/res/layout/recyclerview_item.xml",
"chars": 2343,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n and"
},
{
"path": "demo/src/main/res/layout/sampe_nested_edittext.xml",
"chars": 1184,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "demo/src/main/res/layout/sampe_nested_scrollview.xml",
"chars": 3004,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "demo/src/main/res/layout/sampe_nested_seekbar.xml",
"chars": 1183,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "demo/src/main/res/layout/sample1.xml",
"chars": 3496,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout\n xmlns:android=\"http://schemas.android.com/ap"
},
{
"path": "demo/src/main/res/layout/sample2.xml",
"chars": 2027,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "demo/src/main/res/layout/sample3.xml",
"chars": 1250,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<com.daimajia.swipe.SwipeLayout xmlns:android=\"http://schemas.android.com/apk/re"
},
{
"path": "demo/src/main/res/layout/sample_nested_parent.xml",
"chars": 1302,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout android:id=\"@+id/parent_framelayout\" xmlns:android=\"http://schemas.a"
},
{
"path": "demo/src/main/res/layout/sample_together.xml",
"chars": 739,
"preview": "<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\"\n "
},
{
"path": "demo/src/main/res/menu/my.xml",
"chars": 627,
"preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n "
},
{
"path": "demo/src/main/res/values/colors.xml",
"chars": 346,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"backgroundColor\">#E8E8E0</color>\n <color name=\"ba"
},
{
"path": "demo/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "demo/src/main/res/values/strings.xml",
"chars": 228,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <string name=\"app_name\">AndroidSwipeLayout</string>\n <string "
},
{
"path": "demo/src/main/res/values/styles.xml",
"chars": 203,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"android:style/Theme.Holo.Light.Dark"
},
{
"path": "demo/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Thu Mar 09 16:07:03 CST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 1055,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Settings specified in this file will override any "
},
{
"path": "gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2404,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "library/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "library/build.gradle",
"chars": 658,
"preview": "apply plugin: 'com.android.library'\n\nandroid {\n compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)"
},
{
"path": "library/gradle-mvn-push.gradle",
"chars": 3877,
"preview": "/*\n * Copyright 2013 Chris Banes\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "library/gradle.properties",
"chars": 1385,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Settings specified in this file will override any "
},
{
"path": "library/proguard-rules.pro",
"chars": 667,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /A"
},
{
"path": "library/src/main/AndroidManifest.xml",
"chars": 72,
"preview": "<manifest package=\"com.daimajia.swipe\">\n <application />\n</manifest>\n"
},
{
"path": "library/src/main/java/com/daimajia/swipe/SimpleSwipeListener.java",
"chars": 575,
"preview": "package com.daimajia.swipe;\n\npublic class SimpleSwipeListener implements SwipeLayout.SwipeListener {\n\n @Override\n "
},
{
"path": "library/src/main/java/com/daimajia/swipe/SwipeLayout.java",
"chars": 60207,
"preview": "package com.daimajia.swipe;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graph"
},
{
"path": "library/src/main/java/com/daimajia/swipe/adapters/ArraySwipeAdapter.java",
"chars": 2897,
"preview": "package com.daimajia.swipe.adapters;\n\nimport android.content.Context;\nimport android.view.View;\nimport android.view.View"
},
{
"path": "library/src/main/java/com/daimajia/swipe/adapters/BaseSwipeAdapter.java",
"chars": 2849,
"preview": "package com.daimajia.swipe.adapters;\n\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.Bas"
},
{
"path": "library/src/main/java/com/daimajia/swipe/adapters/CursorSwipeAdapter.java",
"chars": 2232,
"preview": "package com.daimajia.swipe.adapters;\n\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.sup"
},
{
"path": "library/src/main/java/com/daimajia/swipe/adapters/RecyclerSwipeAdapter.java",
"chars": 2011,
"preview": "package com.daimajia.swipe.adapters;\n\nimport android.support.v7.widget.RecyclerView;\nimport android.view.ViewGroup;\n\nimp"
},
{
"path": "library/src/main/java/com/daimajia/swipe/adapters/SimpleCursorSwipeAdapter.java",
"chars": 2246,
"preview": "package com.daimajia.swipe.adapters;\n\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.sup"
},
{
"path": "library/src/main/java/com/daimajia/swipe/implments/SwipeItemMangerImpl.java",
"chars": 6311,
"preview": "package com.daimajia.swipe.implments;\n\nimport android.view.View;\n\nimport com.daimajia.swipe.SimpleSwipeListener;\nimport "
},
{
"path": "library/src/main/java/com/daimajia/swipe/interfaces/SwipeAdapterInterface.java",
"chars": 167,
"preview": "package com.daimajia.swipe.interfaces;\n\npublic interface SwipeAdapterInterface {\n\n int getSwipeLayoutResourceId(int p"
},
{
"path": "library/src/main/java/com/daimajia/swipe/interfaces/SwipeItemMangerInterface.java",
"chars": 573,
"preview": "package com.daimajia.swipe.interfaces;\n\nimport com.daimajia.swipe.SwipeLayout;\nimport com.daimajia.swipe.util.Attributes"
},
{
"path": "library/src/main/java/com/daimajia/swipe/util/Attributes.java",
"chars": 118,
"preview": "package com.daimajia.swipe.util;\n\n\npublic class Attributes {\n\n public enum Mode {\n Single, Multiple\n }\n}\n"
},
{
"path": "library/src/main/res/values/attrs.xml",
"chars": 817,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <declare-styleable name=\"SwipeLayout\">\n <attr name=\"drag_e"
},
{
"path": "settings.gradle",
"chars": 28,
"preview": "include ':demo', ':library'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the daimajia/AndroidSwipeLayout GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 71 files (164.7 KB), approximately 40.0k tokens, and a symbol index with 316 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.