├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── SwipeBack.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cjj
│ │ └── swipeback
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cjj
│ │ └── swipeback
│ │ ├── MainActivity.java
│ │ └── SimpleBookBackDemo.java
│ └── res
│ ├── anim
│ └── right_anim.xml
│ ├── drawable
│ ├── cjj.png
│ ├── jj1.png
│ └── jj2.jpg
│ ├── layout
│ ├── activity_main.xml
│ └── activity_simple_book.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v19
│ ├── dimens.xml
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gif
├── a.png
├── b.png
├── j1.png
├── j2.png
├── j3.png
├── j4.png
├── j5.png
└── jjswipeback.gif
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── library.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cjj
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cjj
│ │ └── SwipeBackLayout.java
│ └── res
│ ├── anim
│ ├── slide_in_right.xml
│ └── slide_out_right.xml
│ ├── drawable
│ └── shadow.png
│ └── values
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Custom
2 | _site
3 |
4 | # Ant
5 | MANIFEST.MF
6 | ./*.jar
7 | build.num
8 | build
9 |
10 | # ADT
11 | .classpath
12 | .project
13 | .settings
14 | local.properties
15 | bin
16 | gen
17 | _layouts
18 | proguard.cfg
19 |
20 | # OSX
21 | .DS_Store
22 |
23 | # Github
24 | gh-pages
25 |
26 | # Gradle
27 | .gradle
28 | build
29 |
30 | # IDEA
31 | *.iml
32 | *.ipr
33 | *.iws
34 | out
35 | .idea
36 |
37 | # Maven
38 | target
39 | release.properties
40 | pom.xml.*
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | SwipeBack
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 1.8
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JJSwipeBack
2 |
3 | activity finish like 简书
4 |
5 | 
6 |
7 | 写了这个之后,谢谢[杨辉](http://github.com/kyze8439690)在微博提醒我,这个已经有开源库了[https://github.com/sockeqwe/SwipeBack](https://github.com/sockeqwe/SwipeBack),所以,简书99%是用了这个.....
8 |
9 | 以下所说都是废话,如果你想快速学习,可以fork或者下载源代码或者看[一步一步教你150行代码实现简书滑动返回效果](http://www.jianshu.com/p/59be4551c418),我不想浪费你时间...
10 |
11 |
12 |
13 |
14 | 其实,网上已经有教程了,我的朋友---[程序亦非猿](https://github.com/AlanCheen)(大神,请允许我抱你大腿)很早就写了[一步一步教你150行代码实现简书滑动返回效果](http://www.jianshu.com/p/59be4551c418),我没看,绝对没看,所以,毫无抄袭的可能,对吧?是吧?吧!(卧槽,你个混蛋,明明抄袭了,还死不承认)。你看,我的名字是JJSwipeBack,是不是很叼(叼你大爷),而且人家要150行,我一行搞定,啊哈哈哈!!!!!!
15 |
16 | 卧槽,其实我也不想的,群里的朋友说写的东西要加个前缀,我这么听话,肯定会做的,啊哈哈哈(哈哈你妹啊)。为什么要写简书的返回呢,因为,前天在那里开了个帐号写小说,虽然粉丝只有几个人(这几个人是被我逼着粉的),这里要打个广告了,这也是我的目的:[我的简书](http://www.jianshu.com/users/cca2dc88f629/latest_articles),对,你会看到一个不一样的[CJJ](https://github.com/android-cjj),不信,请看我简介
17 |
18 | 
19 |
20 | 看到没,是FuckCjj(呵呵,别打我)......
21 |
22 | 看完我的小说的朋友,都打赏了,还给了鼓励的话语感谢[dim](https://github.com/zzz40500)和[鲍老弟](https://github.com/baoyongzhang),排名有分先后,谁钱给的多,谁排前后(啊哈哈,等下又要被打了)
23 |
24 | 
25 |
26 | 你看,都被我写的小说感染了,情绪有点激动,理解,写的实在太好了,我自己都被自己的文采折服......
27 |
28 | 还有穷逼的朋友也写了评论
29 |
30 | 
31 |
32 | 
33 |
34 | 
35 |
36 | 感谢下阿[阿布](https://github.com/nimengbo)、[涛哥](https://github.com/liangzhitao)、[Veaer](https://github.com/Veaer)
37 |
38 | 你没看错,这些读者都快入迷了,是什么小说可以如此的影响一个人呢?是我写的小说就可以,还不去看,小心我f**k 你
39 |
40 |
41 | 我们都是一群豆逼的人儿,我们的群号是:GitHub小伙伴交流群 477826523
42 | 你想加入我们吗,首先github有至少7个关注者并且开源库有7颗星星的,你丫还要是个土豪,可以发红包(又拿别的群的图片来坑蒙拐骗了,啊哈哈哈)
43 |
44 | 以上都是扯淡,如果你看了,请自己洗脑删除。。。。啊哈哈哈。。。。。。。。。。。。。。。。。。。。。。。。
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/SwipeBack.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.cjj.swipeback"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | compile project(':library')
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\as\sdk-install/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/cjj/swipeback/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cjj.swipeback;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cjj/swipeback/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.cjj.swipeback;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 |
10 | import com.cjj.WXSwipeBackActivity;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | }
19 |
20 | @Override
21 | public boolean onCreateOptionsMenu(Menu menu) {
22 | // Inflate the menu; this adds items to the action bar if it is present.
23 | getMenuInflater().inflate(R.menu.menu_main, menu);
24 | return true;
25 | }
26 |
27 | @Override
28 | public boolean onOptionsItemSelected(MenuItem item) {
29 | // Handle action bar item clicks here. The action bar will
30 | // automatically handle clicks on the Home/Up button, so long
31 | // as you specify a parent activity in AndroidManifest.xml.
32 | int id = item.getItemId();
33 |
34 | //noinspection SimplifiableIfStatement
35 | if (id == R.id.action_settings) {
36 | return true;
37 | }
38 |
39 | return super.onOptionsItemSelected(item);
40 | }
41 |
42 | public void onClick(View view)
43 | {
44 | switch (view.getId())
45 | {
46 | case R.id.button:
47 | startActivity(new Intent(this,SimpleBookBackDemo.class));
48 | break;
49 |
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cjj/swipeback/SimpleBookBackDemo.java:
--------------------------------------------------------------------------------
1 | package com.cjj.swipeback;
2 |
3 | import android.os.Bundle;
4 | import android.os.PersistableBundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.RelativeLayout;
7 | import android.widget.TextView;
8 |
9 | import com.cjj.SwipeBackLayout;
10 |
11 | /**
12 | * Created by Administrator on 2015/11/17.
13 | */
14 | public class SimpleBookBackDemo extends AppCompatActivity {
15 | private SwipeBackLayout mSwipeBackLayout;
16 | private TextView tv;
17 | private RelativeLayout rl;
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_simple_book);
22 | rl = (RelativeLayout) findViewById(R.id.rl);
23 | tv = (TextView) findViewById(R.id.tv);
24 | tv.animate().rotation(-90);
25 | mSwipeBackLayout = (SwipeBackLayout) findViewById(R.id.sb);
26 | mSwipeBackLayout.setOnSwipeBackListener(new SwipeBackLayout.SwipeBackListener() {
27 | @Override
28 | public void onOpen() {
29 | finish();
30 | overridePendingTransition(0, R.anim.right_anim);
31 | }
32 |
33 | @Override
34 | public void onClose() {
35 |
36 | }
37 |
38 | @Override
39 | public void onSwipe(float percent) {
40 | rl.setTranslationX(percent * 30 - 30);
41 | tv.setAlpha(percent<0.5?0.1f:percent);
42 | }
43 | });
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/right_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cjj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/drawable/cjj.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/jj1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/drawable/jj1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/jj2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/drawable/jj2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_simple_book.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
18 |
19 |
30 |
31 |
38 |
39 |
40 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v19/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 25dp
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00F5F5F5
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SwipeBack
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
15 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gif/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/a.png
--------------------------------------------------------------------------------
/gif/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/b.png
--------------------------------------------------------------------------------
/gif/j1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/j1.png
--------------------------------------------------------------------------------
/gif/j2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/j2.png
--------------------------------------------------------------------------------
/gif/j3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/j3.png
--------------------------------------------------------------------------------
/gif/j4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/j4.png
--------------------------------------------------------------------------------
/gif/j5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/j5.png
--------------------------------------------------------------------------------
/gif/jjswipeback.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gif/jjswipeback.gif
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 28 11:54:20 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:23.0.1'
24 | }
25 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\as\sdk-install/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/cjj/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cjj;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cjj/SwipeBackLayout.java:
--------------------------------------------------------------------------------
1 | package com.cjj;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.GestureDetectorCompat;
5 | import android.support.v4.view.ViewCompat;
6 | import android.support.v4.widget.ViewDragHelper;
7 | import android.util.AttributeSet;
8 | import android.util.Log;
9 | import android.view.GestureDetector;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.FrameLayout;
14 | import android.widget.RelativeLayout;
15 |
16 | /**
17 | * Created by cjj on 2015/11/17.
18 | */
19 | public class SwipeBackLayout extends FrameLayout {
20 |
21 | /**打印log的tag*/
22 | private final static String Tag = SwipeBackLayout.class.getSimpleName();
23 |
24 | /**内容界面*/
25 | private ViewGroup mContentFrameLayout;
26 |
27 | /**遮盖界面*/
28 | private ViewGroup mBehindFrameLayout;
29 |
30 | /**这个我不知道怎么注释*/
31 | private ViewDragHelper mViewDragHelper;
32 |
33 | /**手势事件类*/
34 | private GestureDetectorCompat mGestureDetectorCompat;
35 |
36 | /**左滑距离*/
37 | private int mSwipeLeft;
38 |
39 | /**左滑最大距离*/
40 | private int mSwipeWidth;
41 |
42 | /**宽度*/
43 | private int mWidth;
44 |
45 | /**高度*/
46 | private int mHeight;
47 |
48 | /**滑动监听*/
49 | private SwipeBackListener mSwipeBackListener;
50 |
51 | /**枚举,默认关闭*/
52 | private SwipeBackStatusEnum mStatus = SwipeBackStatusEnum.Close;
53 |
54 | /**
55 | * 构造函数,然并卵,写成习惯了
56 | * @param context
57 | */
58 | public SwipeBackLayout(Context context) {
59 | super(context);
60 | init();
61 | }
62 |
63 | public SwipeBackLayout(Context context, AttributeSet attrs) {
64 | super(context, attrs);
65 | init();
66 | }
67 |
68 |
69 | public SwipeBackLayout(Context context, AttributeSet attrs, int defStyle) {
70 | super(context, attrs, defStyle);
71 | init();
72 | }
73 |
74 | /**
75 | * 初始化
76 | */
77 | private void init() {
78 | mViewDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback());//创建ViewDragHelper的实例,第一个参数是ViewGroup,传自己,第二个灵敏度,一般正常是1.0,不正常你自己写,第三个是回调,看下面...
79 | mGestureDetectorCompat = new GestureDetectorCompat(getContext(), new XScrollDetector());//手势操作,第二参数什么意思看下面
80 | }
81 |
82 | /**
83 | * View 中所有的子控件均被映射成xml后触发
84 | */
85 | @Override
86 | protected void onFinishInflate() {
87 | mBehindFrameLayout = (RelativeLayout) getChildAt(0);
88 | mContentFrameLayout = (RelativeLayout) getChildAt(1);
89 | mBehindFrameLayout.setClickable(true);
90 | mContentFrameLayout.setClickable(true);
91 | super.onFinishInflate();
92 | }
93 |
94 | /**
95 | * 手势监听回调
96 | */
97 | class XScrollDetector extends GestureDetector.SimpleOnGestureListener {//SimpleOnGestureListener为了不用重写那么多监听的帮助类
98 | @Override
99 | public boolean onScroll(MotionEvent e1, MotionEvent e2,
100 | float distanceX, float distanceY) {
101 | return Math.abs(distanceY) <= Math.abs(distanceX);//判断是否是滑动的x距离>y距离
102 | }
103 | }
104 |
105 | /**
106 | * 枚举的三种状态
107 | */
108 | public enum SwipeBackStatusEnum {
109 |
110 | swipe,
111 |
112 | Open,
113 |
114 | Close
115 | }
116 |
117 | public interface SwipeBackListener {
118 | /**打开*/
119 | public void onOpen();
120 |
121 | /**关闭*/
122 | public void onClose();
123 |
124 | /**滑动*/
125 | public void onSwipe(float percent);
126 |
127 | }
128 |
129 |
130 | /**
131 | * 事件拦截
132 | * @param ev
133 | * @return
134 | */
135 | @Override
136 | public boolean onInterceptTouchEvent(MotionEvent ev) {
137 | return mViewDragHelper.shouldInterceptTouchEvent(ev) && mGestureDetectorCompat.onTouchEvent(ev);
138 | }
139 |
140 | /**
141 | * 事件监听,交给ViewDragHelper处理
142 | * @param e
143 | * @return
144 | */
145 | @Override
146 | public boolean onTouchEvent(MotionEvent e) {
147 | try {
148 | mViewDragHelper.processTouchEvent(e);
149 | } catch (Exception ex) {
150 | ex.printStackTrace();
151 | }
152 | return false;
153 | }
154 |
155 | /**
156 | * 当view的大小发生变化时触发
157 | * @param w
158 | * @param h
159 | * @param oldw
160 | * @param oldh
161 | */
162 | @Override
163 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
164 | super.onSizeChanged(w, h, oldw, oldh);
165 | mWidth = mBehindFrameLayout.getMeasuredWidth();
166 | mHeight = mBehindFrameLayout.getMeasuredHeight();
167 | mSwipeWidth = (int) (mWidth * 0.15);
168 | }
169 |
170 | /**
171 | * 测量之后,子控件找自己的位置摆放自己
172 | * @param changed
173 | * @param left
174 | * @param top
175 | * @param right
176 | * @param bottom
177 | */
178 | @Override
179 | protected void onLayout(boolean changed, int left, int top, int right,
180 | int bottom) {
181 | mBehindFrameLayout.layout(0, 0, mWidth, mHeight);
182 | mContentFrameLayout.layout(mSwipeLeft, 0, mSwipeLeft + mWidth, mHeight);
183 | }
184 |
185 |
186 | /**
187 | * 设置监听
188 | * @param swipeBackListener
189 | */
190 | public void setOnSwipeBackListener(SwipeBackListener swipeBackListener) {
191 | this.mSwipeBackListener = swipeBackListener;
192 | }
193 |
194 |
195 | /**
196 | * 打开
197 | */
198 | public void open() {
199 | if (mViewDragHelper.smoothSlideViewTo(mContentFrameLayout, mSwipeWidth, 0)) {
200 | ViewCompat.postInvalidateOnAnimation(this);
201 | }
202 | if (null != mSwipeBackListener) mSwipeBackListener.onOpen();
203 |
204 | }
205 |
206 |
207 | /**
208 | * 关闭
209 | */
210 | public void close() {
211 | if (mViewDragHelper.smoothSlideViewTo(mContentFrameLayout, 0, 0)) {
212 | ViewCompat.postInvalidateOnAnimation(this);
213 | }
214 | }
215 |
216 | /**
217 | * 主要是回调监听
218 | * @param swipeLeft
219 | */
220 | private void dispatchSwipeEvent(int swipeLeft) {
221 | if (mSwipeBackListener == null) {
222 | return;
223 | }
224 | float percent = swipeLeft / (float) mSwipeWidth;
225 | mSwipeBackListener.onSwipe(percent);
226 | SwipeBackStatusEnum lastStatus = mStatus;
227 | if (lastStatus != getStatus() && mStatus == SwipeBackStatusEnum.Close) {
228 | mBehindFrameLayout.setEnabled(false);
229 | mSwipeBackListener.onClose();
230 | } else if (lastStatus != getStatus() && mStatus == SwipeBackStatusEnum.Open) {
231 | mBehindFrameLayout.setEnabled(true);
232 | // mSwipeBackListener.onOpen();
233 | }
234 | }
235 |
236 | /**
237 | * 获取当前的状态
238 | * @return
239 | */
240 | public SwipeBackStatusEnum getStatus() {
241 | int mainLeft = mContentFrameLayout.getLeft();
242 | if (mainLeft == 0) {
243 | mStatus = SwipeBackStatusEnum.Close;
244 | } else if (mainLeft == mSwipeWidth) {
245 | mStatus = SwipeBackStatusEnum.Open;
246 | } else {
247 | mStatus = SwipeBackStatusEnum.swipe;
248 | }
249 | return mStatus;
250 | }
251 |
252 | /**
253 | *draw() 过程 调用 该 方法
254 | */
255 | @Override
256 | public void computeScroll() {
257 | if (mViewDragHelper.continueSettling(true)) {
258 | ViewCompat.postInvalidateOnAnimation(this);
259 | }
260 | }
261 |
262 |
263 | /**
264 | * 卧槽,终于到重点部分了,好好听着,f**k,写注释好累.....不想写了
265 | * 推荐你看下翔哥的:http://blog.csdn.net/lmj623565791/article/details/46858663
266 | * 看懂我就不用解释了,啊哈哈...(打我可以,来 GitHub小伙伴交流群 477826523 )
267 | */
268 | private class DragHelperCallback extends ViewDragHelper.Callback {
269 | @Override
270 | public boolean tryCaptureView(View child, int pointerId) {
271 | return true;
272 | }
273 |
274 | @Override
275 | public int getViewHorizontalDragRange(View child) {
276 | return mWidth;
277 | }
278 |
279 | @Override
280 | public int clampViewPositionHorizontal(View child, int left, int dx) {
281 | if (mSwipeLeft + dx < 0) {
282 | return 0;
283 | } else if (mSwipeLeft + dx > mSwipeWidth) {
284 | return mSwipeWidth;
285 | } else {
286 | return left;
287 | }
288 | }
289 |
290 | @Override
291 | public void onViewReleased(View releasedChild, float xvel, float yvel) {
292 | Log.i(Tag,"onViewReleased");
293 | if (xvel > 0) {
294 | openEvent();
295 | } else if (xvel < 0) {
296 | close();
297 | } else if (releasedChild == mContentFrameLayout && mSwipeLeft > mSwipeWidth * 0.4) {
298 | openEvent();
299 | } else if (releasedChild == mBehindFrameLayout && mSwipeLeft > mSwipeWidth * 0.6) {
300 | openEvent();
301 | } else {
302 | close();
303 | }
304 | }
305 |
306 | public void openEvent()
307 | {
308 | if (mViewDragHelper.smoothSlideViewTo(mContentFrameLayout, mSwipeWidth, 0)) {
309 | ViewCompat.postInvalidateOnAnimation(SwipeBackLayout.this);
310 | }
311 |
312 | SwipeBackLayout.this.postDelayed(new Runnable() {
313 | @Override
314 | public void run() {
315 | if (null != mSwipeBackListener) mSwipeBackListener.onOpen();
316 | }
317 | }, 200);
318 | }
319 |
320 | @Override
321 | public void onViewPositionChanged(View changedView, int left, int top,
322 | int dx, int dy) {
323 | Log.i(Tag,"onViewPositionChanged");
324 | if (changedView == mContentFrameLayout) {
325 | mSwipeLeft = left;
326 | } else {
327 | mSwipeLeft = mSwipeLeft + left;
328 | }
329 | if (mSwipeLeft < 0) {
330 | mSwipeLeft = 0;
331 | } else if (mSwipeLeft > mSwipeWidth) {
332 | mSwipeLeft = mSwipeWidth;
333 | }
334 | dispatchSwipeEvent(mSwipeLeft);
335 | if (changedView == mBehindFrameLayout) {
336 | mBehindFrameLayout.layout(0, 0, mWidth, mHeight);
337 | mContentFrameLayout.layout(mSwipeLeft, 0, mSwipeLeft + mWidth, mHeight);
338 | }
339 | invalidate();
340 | }
341 | }
342 | }
343 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/slide_in_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/slide_out_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/JJSwipeBack/c309f505f860ef90af8dabb74723773944fab7de/library/src/main/res/drawable/shadow.png
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------