├── .gradle
├── 6.1.1
│ ├── gc.properties
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ └── fileHashes.lock
│ └── executionHistory
│ │ ├── executionHistory.bin
│ │ └── executionHistory.lock
├── vcs-1
│ └── gc.properties
├── buildOutputCleanup
│ ├── cache.properties
│ ├── outputFiles.bin
│ └── buildOutputCleanup.lock
└── checksums
│ └── checksums.lock
├── Drawer
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── layout
│ │ │ │ │ ├── open_handle.xml
│ │ │ │ │ ├── open_content.xml
│ │ │ │ │ ├── test_drag.xml
│ │ │ │ │ ├── activity_drawer.xml
│ │ │ │ │ └── activity_main.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── drawer
│ │ │ │ ├── DrawerActivity.java
│ │ │ │ ├── TextDragLayout.java
│ │ │ │ └── MainActivity.java
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── drawer
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── yanxuwen
│ │ │ └── drawer
│ │ │ └── ExampleInstrumentedTest.java
│ ├── build.gradle
│ └── proguard-rules.pro
├── mydrawer
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ └── attrs.xml
│ │ │ │ └── anim
│ │ │ │ │ ├── fare_out.xml
│ │ │ │ │ └── fare_in.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── mydrawer
│ │ │ │ ├── RecyclerViewImpl.java
│ │ │ │ ├── NotchScreenUtils.java
│ │ │ │ ├── DrawerLayout.java
│ │ │ │ └── BaseDragLayout.java
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── mydrawer
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── yanxuwen
│ │ │ └── mydrawer
│ │ │ └── ExampleInstrumentedTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── .idea
│ ├── caches
│ │ ├── gradle_models.ser
│ │ └── build_file_checksums.ser
│ ├── compiler.xml
│ ├── vcs.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── jarRepositories.xml
│ ├── codeStyles
│ │ └── Project.xml
│ └── dbnavigator.xml
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradle.properties
├── install.gradle
├── bintray.gradle
├── gradlew.bat
└── gradlew
├── TestApplication
├── app
│ ├── .gitignore
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── layout
│ │ │ │ │ └── activity_main.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── testapplication
│ │ │ │ └── MainActivity.java
│ │ ├── test
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── yanxuwen
│ │ │ │ └── testapplication
│ │ │ │ └── ExampleUnitTest.java
│ │ └── androidTest
│ │ │ └── java
│ │ │ └── com
│ │ │ └── yanxuwen
│ │ │ └── testapplication
│ │ │ └── ExampleInstrumentedTest.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── .idea
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── gradle.xml
│ ├── compiler.xml
│ └── misc.xml
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
├── .idea
├── vcs.xml
├── compiler.xml
├── misc.xml
├── gradle.xml
└── workspace.xml
├── gradle
└── wrapper
│ └── gradle-wrapper.properties
├── local.properties
├── .gitignore
├── README.md
├── gradlew.bat
└── gradlew
/.gradle/6.1.1/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Drawer/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/TestApplication/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/TestApplication/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/Drawer/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':mydrawer'
2 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 08 14:21:38 CST 2021
2 | gradle.version=6.1.1
3 |
--------------------------------------------------------------------------------
/.gradle/checksums/checksums.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/checksums/checksums.lock
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Drawer
3 |
4 |
--------------------------------------------------------------------------------
/Drawer/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/6.1.1/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/6.1.1/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | myDrawer
3 |
4 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/TestApplication/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Drawer/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TestApplication
3 |
4 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/.gradle/6.1.1/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/6.1.1/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/.gradle/6.1.1/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/Drawer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Drawer/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/TestApplication/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanxuwen/MyDrawer/HEAD/TestApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Drawer/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Drawer/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Drawer/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 06 13:24:44 CST 2020
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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/TestApplication/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 20 15:45:44 CST 2018
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Mon Mar 08 14:21:39 CST 2021
8 | sdk.dir=E\:\\sdk
9 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/res/anim/fare_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/res/anim/fare_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/Drawer/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TestApplication/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/java/com/yanxuwen/mydrawer/RecyclerViewImpl.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * @author bsnl_yanxuwen
7 | * @date 2021/3/8 14:59
8 | * Description :
9 | */
10 | public interface RecyclerViewImpl {
11 | boolean canScrollHorizontally(int direction);
12 |
13 | boolean canScrollVertically(int direction);
14 |
15 | View getRecyclerView();
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Drawer/app/src/test/java/com/yanxuwen/drawer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.drawer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/test/java/com/yanxuwen/mydrawer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/TestApplication/app/src/test/java/com/yanxuwen/testapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.testapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/layout/open_handle.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/layout/open_content.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/Drawer/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TestApplication/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:2.3.1'
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 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Drawer/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/TestApplication/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/layout/test_drag.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
16 |
17 |
--------------------------------------------------------------------------------
/TestApplication/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/TestApplication/.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 |
--------------------------------------------------------------------------------
/TestApplication/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Drawer/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "28.0.3"
6 | defaultConfig {
7 | applicationId "com.yanxuwen.drawer"
8 | minSdkVersion 18
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | implementation 'com.android.support:appcompat-v7:28.0.0'
25 | implementation project(path: ':mydrawer')
26 | }
27 |
--------------------------------------------------------------------------------
/Drawer/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 | maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
13 | }
14 |
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
20 | maven { url 'https://jitpack.io' }
21 | jcenter()
22 | google()
23 | }
24 | }
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Drawer/app/src/androidTest/java/com/yanxuwen/drawer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.drawer;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yanxuwen.drawer", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/androidTest/java/com/yanxuwen/mydrawer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yanxuwen.mydrawer.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/TestApplication/app/src/androidTest/java/com/yanxuwen/testapplication/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.testapplication;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.yanxuwen.testapplication", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/java/com/yanxuwen/drawer/DrawerActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.drawer;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.widget.Toast;
7 |
8 | import com.yanxuwen.mydrawer.DrawerLayout;
9 |
10 | public class DrawerActivity extends Activity implements DrawerLayout.OnDrawerStatusListener {
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_drawer);
15 | final DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.dragLayout);
16 | new Handler().postDelayed(new Runnable() {
17 |
18 | @Override
19 | public void run() {
20 | mDrawerLayout.open();
21 | }
22 | }, 5000);
23 | mDrawerLayout.setOnDrawerStatusListener(this);
24 | }
25 |
26 | @Override
27 | public void onStatus(boolean isOpen) {
28 | Toast.makeText(this, isOpen ? "打开" : "关闭", Toast.LENGTH_LONG).show();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Drawer/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Drawer/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 E:\studio\android_sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/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 E:\studio\android_sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/TestApplication/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:\android-sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/layout/activity_drawer.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
17 |
18 |
21 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/TestApplication/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.yanxuwen.testapplication"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.+'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | }
31 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayName = 'mydrawer'
5 | artifact = bintrayName
6 | libraryName = 'mydrawer'
7 | libraryDescription = 'mydrawer'
8 | libraryVersion = main_version
9 | }
10 |
11 | android {
12 | compileSdkVersion 28
13 | buildToolsVersion "28.0.3"
14 | defaultConfig {
15 | minSdkVersion 15
16 | targetSdkVersion 28
17 | versionCode 1
18 | versionName "1.0"
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 | javaCompileOptions {
21 | annotationProcessorOptions {
22 | includeCompileClasspath true
23 | }
24 | }
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | }
32 | }
33 | dependencies {
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | implementation 'com.android.support:appcompat-v7:28.0.0'
36 | }
37 |
38 | apply from: '../install.gradle'
39 | apply from: '../bintray.gradle'
40 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/java/com/yanxuwen/drawer/TextDragLayout.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.drawer;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 | import android.widget.Toast;
9 |
10 | import com.yanxuwen.mydrawer.BaseDragLayout;
11 |
12 | /**
13 | * 作者:严旭文 on 2017/2/16 15:37
14 | * 邮箱:420255048@qq.com
15 | */
16 | public class TextDragLayout extends BaseDragLayout {
17 | ImageView iv_cover;
18 | public TextDragLayout(Context context) {
19 | super(context);
20 | }
21 |
22 | public TextDragLayout(Context context, AttributeSet attrs) {
23 | super(context, attrs, 0);
24 | }
25 |
26 | public TextDragLayout(Context context, AttributeSet attrs, int defStyle) {
27 | super(context, attrs, defStyle);
28 | }
29 |
30 | @Override
31 | public void onViewStatus(boolean isOpen) {
32 |
33 | }
34 |
35 | @Override
36 | public void onViewOffset(float mOffset) {
37 | if(iv_cover!=null){
38 | iv_cover.setAlpha((float) (mOffset*0.8));
39 | }
40 | }
41 |
42 | @Override
43 | public void initView() {
44 | iv_cover= (ImageView) findViewById(R.id.iv_cover);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Drawer/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | # When configured, Gradle will run in incubating parallel mode.
10 | # This option should only be used with decoupled projects. More details, visit
11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12 | # org.gradle.parallel=true
13 | org.gradle.daemon=true
14 |
15 | bintrayRepo=maven
16 | main_version=1.2.2
17 | publishedGroupId=com.yanxuwen.mydrawer
18 | siteUrl=https://github.com/yanxuwen/mydrawer
19 | gitUrl=https://github.com/yanxuwen/mydrawer.git
20 | developerId=yxe
21 | developerName=yanxuwen
22 | developerEmail=420255048@qq.com
23 | #android.useAndroidX=true
24 | #android.enableJetifier=true
25 |
26 |
27 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
28 |
29 | #org.gradle.jvmargs= -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005,
30 | #Dorg.gradle.debug=true
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Drawer/install.gradle:
--------------------------------------------------------------------------------
1 | // backup of [https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle]
2 |
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 | group = publishedGroupId // Maven Group ID for the artifact
6 |
7 | install {
8 | repositories.mavenInstaller {
9 | // This generates POM.xml with proper parameters
10 | pom {
11 | project {
12 | packaging 'aar'
13 | groupId publishedGroupId
14 | artifactId artifact
15 |
16 | // Add your description here
17 | name libraryName
18 | description libraryDescription
19 | url siteUrl
20 |
21 | // Set your license
22 | licenses {
23 | license {
24 | name 'The Apache Software License, Version 2.0'
25 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
26 | }
27 | }
28 | developers {
29 | developer {
30 | id developerId
31 | name developerName
32 | email developerEmail
33 | }
34 | }
35 | scm {
36 | connection gitUrl
37 | developerConnection gitUrl
38 | url siteUrl
39 |
40 | }
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Drawer/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/Drawer/app/src/main/java/com/yanxuwen/drawer/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.drawer;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.util.Log;
7 | import android.view.KeyEvent;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import com.yanxuwen.mydrawer.BaseDragLayout;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 | TextDragLayout mTextDragLayout;
15 |
16 |
17 |
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 |
24 | mTextDragLayout = (TextDragLayout)findViewById(R.id.includ_text_drag);
25 | mTextDragLayout.setMoveEventSize(200);
26 |
27 | }
28 | public void onFullRight(View v){
29 | if (mTextDragLayout.isOpen()){
30 | mTextDragLayout.close(BaseDragLayout.MODE_DRAG_RIGHT);
31 | } else {
32 | mTextDragLayout.open(BaseDragLayout.MODE_DRAG_RIGHT);
33 | }
34 | }
35 |
36 | public void onFullLeft(View v){
37 | if (mTextDragLayout.isOpen()){
38 | mTextDragLayout.close(BaseDragLayout.MODE_DRAG_LEFT);
39 | } else {
40 | mTextDragLayout.open(BaseDragLayout.MODE_DRAG_LEFT);
41 | } }
42 |
43 | public void onFullBottom(View v){
44 | Toast.makeText(this,"没有设置",Toast.LENGTH_SHORT).show();
45 | }
46 |
47 | public void onFullTop(View v){
48 | Toast.makeText(this,"没有设置",Toast.LENGTH_SHORT).show();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/TestApplication/app/src/main/java/com/yanxuwen/testapplication/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.testapplication;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.webkit.WebSettings;
6 | import android.webkit.WebView;
7 | import android.webkit.WebViewClient;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | String url="http://project.gmm-zc.cn/hesk/ylys/雁庐馆演示.html";
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 | WebView webview = (WebView) findViewById(R.id.webview);
17 | WebSettings webSettings = webview.getSettings();
18 | webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
19 | webview.setInitialScale(50);
20 | webSettings.setJavaScriptEnabled(true);
21 | webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
22 | webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
23 | //缩放操作
24 | webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
25 | webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
26 | webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件
27 | //其他细节操作
28 | webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
29 | webSettings.setAllowFileAccess(true); //设置可以访问文件
30 | webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
31 | webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
32 | webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式
33 | //布局内跳转
34 | webview.setWebViewClient(new WebViewClient(){
35 | @Override
36 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
37 | view.loadUrl(url); //在当前的webview中跳转到新的url
38 | return true;
39 | }
40 | });
41 | webview.loadUrl(url);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/Drawer/bintray.gradle:
--------------------------------------------------------------------------------
1 | // backup of [https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle]
2 |
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | version = libraryVersion
6 |
7 | if (project.hasProperty("android")) { // Android libraries
8 | task sourcesJar(type: Jar) {
9 | classifier = 'sources'
10 | from android.sourceSets.main.java.srcDirs
11 | }
12 |
13 | task javadoc(type: Javadoc) {
14 | source = android.sourceSets.main.java.srcDirs
15 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
16 | }
17 | } else { // Java libraries
18 | task sourcesJar(type: Jar, dependsOn: classes) {
19 | classifier = 'sources'
20 | from sourceSets.main.allSource
21 | }
22 | }
23 |
24 | task javadocJar(type: Jar, dependsOn: javadoc) {
25 | classifier = 'javadoc'
26 | from javadoc.destinationDir
27 | }
28 |
29 | artifacts {
30 | archives javadocJar
31 | archives sourcesJar
32 | }
33 |
34 | javadoc {
35 | failOnError false
36 | options{
37 | encoding "UTF-8"
38 | charSet 'UTF-8'
39 | author true
40 | version true
41 | links "http://docs.oracle.com/javase/7/docs/api"
42 | }
43 | }
44 |
45 | // Bintray
46 | Properties properties = new Properties()
47 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
48 |
49 | bintray {
50 | user = properties.getProperty("bintray.user")
51 | key = properties.getProperty("bintray.apikey")
52 |
53 | configurations = ['archives']
54 | pkg {
55 | repo = "maven"
56 | name = bintrayName
57 | desc = libraryDescription
58 | websiteUrl = siteUrl
59 | vcsUrl = gitUrl
60 | licenses = ["Apache-2.0"]
61 | publish = true
62 | publicDownloadNumbers = true
63 | version {
64 | desc = libraryDescription
65 | gpg {
66 | sign = true //Determines whether to GPG sign the files. The default is false
67 | passphrase = properties.getProperty("bintray.gpg.password")
68 | //Optional. The passphrase for GPG signing'
69 | }
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/Drawer/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
47 |
52 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Drawer/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 |
--------------------------------------------------------------------------------
/TestApplication/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 |
--------------------------------------------------------------------------------
/TestApplication/.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 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # 前言 该抽屉实现了可以定义4边的抽屉,大小随意控制。可实现(仿今日头条的评论抽屉功能)
3 | #### 博客地址:https://www.jianshu.com/p/2abb8c20817f
4 |
5 | ## 先看下效果图
6 | 
7 |
8 | # 依赖:
9 | compile 'com.yanxuwen.mydrawer:mydrawer:1.2.2’
10 | # 实现:
11 | #### 1.首先自定义类。TextDragLayout
12 | ~~~
13 | public class TextDragLayout extends BaseDragLayout {
14 | ImageView iv_cover;
15 | public TextDragLayout(Context context) {
16 | super(context);
17 | }
18 |
19 | public TextDragLayout(Context context, AttributeSet attrs) {
20 | super(context, attrs, 0);
21 | }
22 |
23 | public TextDragLayout(Context context, AttributeSet attrs, int defStyle) {
24 | super(context, attrs, defStyle);
25 | }
26 | @Override
27 | public void onViewStatus(boolean isOpen) {
28 | }
29 |
30 | @Override
31 | public void onViewOffset(float mOffset) {
32 | if(iv_cover!=null){
33 | iv_cover.setAlpha((float) (mOffset*0.8));
34 | }
35 | }
36 |
37 | @Override
38 | public void initView() {
39 | setContentView(findViewById(R.id.layout_drag));
40 | iv_cover= (ImageView) findViewById(R.id.iv_cover);
41 | }
42 | }
43 | ~~~
44 | 其实就是继承BaseDragLayout,onViewStatus开关回调,onViewOffset是偏移量回调,initView不想说了。其实没什么东西,这里可以实现你自己的逻辑。
45 |
46 | #### 2.xml设置(在你需要的界面上加上该布局)
47 | ~~~
48 |
49 |
55 |
56 |
63 |
64 |
65 |
66 | ~~~
67 | 代码iv_cover其实就是阴影部分,由于我们不提供任何阴影的控制,因为不同的需求,阴影不同,所以我们设置阴影很简单,就是在布局在加个子类,透明度为0然后在TextDragLayout 的onViewOffset偏移量回调控制阴影透明度变化,这样就会实现阴影效果。
68 |
69 | #3.MainActivity
70 | ~~~
71 | 打开我们只需要mTextDragLayout.open();
72 | 关闭只需要 mTextDragLayout.close();
73 | //提供是否可以根据手势滑动,默认true, false为关闭
74 | mTextDragLayout.setSlideable(true);
75 | //提供是否可以滑动屏幕边缘来展开抽屉,默认true, false为关闭功能
76 | mTextDragLayout.isEdgeSlide(true);
77 | 记得在控制back键,返回的时候我们要关闭掉
78 | public boolean onKeyDown(int keyCode, KeyEvent event) {
79 | // TODO Auto-generated method stub
80 | if (keyCode == KeyEvent.KEYCODE_BACK) {
81 | if (mTextDragLayout != null && mTextDragLayout.isOpen()) {
82 | mTextDragLayout.close();
83 | return true;
84 | } else{
85 | finish();
86 | }
87 |
88 | }
89 | return false;
90 | }
91 | ~~~
92 | # 4.基本流程就是这样,很简单,但是如果你要实现类似今日头条那样,有个列表,由于都是上下滑动,所以会导致列表不会滑动,之后滑动抽屉,我们只要简单的加上下面这句话即可
93 | ~~~
94 | mTextDragLayout.setRecyclerView(mRecyclerView);
95 | 加了上面那句话你就会发现,会先滑动列表,列表滑动到顶才会滑动抽屉,是不是跟今日头条一样,支持4个方向的冲突,
96 | ~~~
97 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/.idea/workspace.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 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | 1615184485990
66 |
67 |
68 | 1615184485990
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/java/com/yanxuwen/mydrawer/NotchScreenUtils.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.Resources;
6 | import android.os.Build;
7 | import android.view.DisplayCutout;
8 | import android.view.View;
9 | import android.view.WindowInsets;
10 |
11 | import java.lang.reflect.InvocationTargetException;
12 | import java.lang.reflect.Method;
13 |
14 | public class NotchScreenUtils {
15 | /**
16 | * 判断是否是刘海屏
17 | * @return
18 | */
19 | public static boolean hasNotchScreen(Activity activity){
20 | if (getInt("ro.miui.notch",activity) == 1 || hasNotchAtHuawei(activity) || hasNotchAtOPPO(activity)
21 | || hasNotchAtVivo(activity) || isAndroidP(activity) != null){ //TODO 各种品牌
22 | return true;
23 | }
24 |
25 | return false;
26 | }
27 |
28 | /**
29 | * Android P 刘海屏判断
30 | * @param activity
31 | * @return
32 | */
33 | public static DisplayCutout isAndroidP(Activity activity){
34 | View decorView = activity.getWindow().getDecorView();
35 | if (decorView != null && android.os.Build.VERSION.SDK_INT >= 28){
36 | WindowInsets windowInsets = decorView.getRootWindowInsets();
37 | if (windowInsets != null)
38 | return windowInsets.getDisplayCutout();
39 | }
40 | return null;
41 | }
42 |
43 | /**
44 | * 小米刘海屏判断.
45 | * @return 0 if it is not notch ; return 1 means notch
46 | * @throws IllegalArgumentException if the key exceeds 32 characters
47 | */
48 | public static int getInt(String key,Activity activity) {
49 | int result = 0;
50 | if ("Xiaomi".equals(Build.MANUFACTURER)){
51 | try {
52 | ClassLoader classLoader = activity.getClassLoader();
53 | @SuppressWarnings("rawtypes")
54 | Class SystemProperties = classLoader.loadClass("android.os.SystemProperties");
55 | //参数类型
56 | @SuppressWarnings("rawtypes")
57 | Class[] paramTypes = new Class[2];
58 | paramTypes[0] = String.class;
59 | paramTypes[1] = int.class;
60 | Method getInt = SystemProperties.getMethod("getInt", paramTypes);
61 | //参数
62 | Object[] params = new Object[2];
63 | params[0] = new String(key);
64 | params[1] = new Integer(0);
65 | result = (Integer) getInt.invoke(SystemProperties, params);
66 |
67 | } catch (ClassNotFoundException e) {
68 | e.printStackTrace();
69 | } catch (NoSuchMethodException e) {
70 | e.printStackTrace();
71 | } catch (IllegalAccessException e) {
72 | e.printStackTrace();
73 | } catch (IllegalArgumentException e) {
74 | e.printStackTrace();
75 | } catch (InvocationTargetException e) {
76 | e.printStackTrace();
77 | }
78 | }
79 | return result;
80 | }
81 |
82 | /**
83 | * 华为刘海屏判断
84 | * @return
85 | */
86 | public static boolean hasNotchAtHuawei(Context context) {
87 | boolean ret = false;
88 | try {
89 | ClassLoader classLoader = context.getClassLoader();
90 | Class HwNotchSizeUtil = classLoader.loadClass("com.huawei.android.util.HwNotchSizeUtil");
91 | Method get = HwNotchSizeUtil.getMethod("hasNotchInScreen");
92 | ret = (boolean) get.invoke(HwNotchSizeUtil);
93 | } catch (Exception e) {
94 | } finally {
95 | return ret;
96 | }
97 | }
98 |
99 | public static final int VIVO_NOTCH = 0x00000020;//是否有刘海
100 | public static final int VIVO_FILLET = 0x00000008;//是否有圆角
101 |
102 | /**
103 | * VIVO刘海屏判断
104 | * @return
105 | */
106 | public static boolean hasNotchAtVivo(Context context) {
107 | boolean ret = false;
108 | try {
109 | ClassLoader classLoader = context.getClassLoader();
110 | Class FtFeature = classLoader.loadClass("android.util.FtFeature");
111 | Method method = FtFeature.getMethod("isFeatureSupport", int.class);
112 | ret = (boolean) method.invoke(FtFeature, VIVO_NOTCH);
113 | } catch (ClassNotFoundException e) {
114 | } catch (NoSuchMethodException e) {
115 | } catch (Exception e) {
116 | } finally {
117 | return ret;
118 | }
119 | }
120 | /**
121 | * OPPO刘海屏判断
122 | * @return
123 | */
124 | public static boolean hasNotchAtOPPO(Context context) {
125 | return context.getPackageManager().hasSystemFeature("com.oppo.feature.screen.heteromorphism");
126 | }
127 |
128 | /**
129 | * 获得状态栏的高度
130 | *
131 | * @param context
132 | * @return
133 | */
134 | public static int getStatusHeight(Context context)
135 | {
136 |
137 | int statusHeight = -1;
138 | try
139 | {
140 | Class> clazz = Class.forName("com.android.internal.R$dimen");
141 | Object object = clazz.newInstance();
142 | int height = Integer.parseInt(clazz.getField("status_bar_height")
143 | .get(object).toString());
144 | statusHeight = context.getResources().getDimensionPixelSize(height);
145 | } catch (Exception e)
146 | {
147 | e.printStackTrace();
148 | }
149 | return statusHeight;
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/Drawer/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/TestApplication/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Drawer/.idea/codeStyles/Project.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 |
58 |
59 |
60 |
61 | xmlns:android
62 |
63 | ^$
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | xmlns:.*
73 |
74 | ^$
75 |
76 |
77 | BY_NAME
78 |
79 |
80 |
81 |
82 |
83 |
84 | .*:id
85 |
86 | http://schemas.android.com/apk/res/android
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | .*:name
96 |
97 | http://schemas.android.com/apk/res/android
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | name
107 |
108 | ^$
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | style
118 |
119 | ^$
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 | .*
129 |
130 | ^$
131 |
132 |
133 | BY_NAME
134 |
135 |
136 |
137 |
138 |
139 |
140 | .*
141 |
142 | http://schemas.android.com/apk/res/android
143 |
144 |
145 | ANDROID_ATTRIBUTE_ORDER
146 |
147 |
148 |
149 |
150 |
151 |
152 | .*
153 |
154 | .*
155 |
156 |
157 | BY_NAME
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=`expr $i + 1`
158 | done
159 | case $i in
160 | 0) set -- ;;
161 | 1) set -- "$args0" ;;
162 | 2) set -- "$args0" "$args1" ;;
163 | 3) set -- "$args0" "$args1" "$args2" ;;
164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=`save "$@"`
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | exec "$JAVACMD" "$@"
184 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/java/com/yanxuwen/mydrawer/DrawerLayout.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.support.v4.view.MotionEventCompat;
6 | import android.support.v4.view.ViewCompat;
7 | import android.support.v4.widget.ViewDragHelper;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | /**
15 | * Created by Flavien Laurent (flavienlaurent.com) on 23/08/13.
16 | */
17 | public class DrawerLayout extends ViewGroup {
18 | private int mHandleId;
19 | private int mContentId;
20 | public static final int ORIENTATION_LEFT = 0;
21 | public static final int ORIENTATION_RIGHT = 1;
22 | public static final int ORIENTATION_TOP = 2;
23 | public static final int ORIENTATION_BOTTOM = 3;
24 |
25 | public int mdirection =ORIENTATION_BOTTOM;
26 | private final ViewDragHelper mDragHelper;
27 | private View mDescView;
28 | private View content;
29 | private float mInitialMotionX;
30 | private float mInitialMotionY;
31 | /** 可拖动范围(总范围) */
32 | private int mDragRange;
33 | private int mTop;
34 | /** 拖动偏移=拖动的量/可拖动的范围(总范围) 大于0.5f则代表为超过一半 */
35 | private float mDragOffset;
36 | /** 判断是否可拖动 */
37 | private boolean isDrawer = true;
38 |
39 | public interface OnDrawerStatusListener {
40 | public void onStatus(boolean isOpen);
41 | }
42 |
43 | OnDrawerStatusListener mOnDrawerStatusListener = null;
44 |
45 | public void setOnDrawerStatusListener(OnDrawerStatusListener l) {
46 | mOnDrawerStatusListener = l;
47 | }
48 |
49 | public DrawerLayout(Context context) {
50 | this(context, null);
51 | }
52 |
53 | public DrawerLayout(Context context, AttributeSet attrs) {
54 | this(context, attrs, 0);
55 | }
56 |
57 | public DrawerLayout(Context context, AttributeSet attrs, int defStyle) {
58 | super(context, attrs, defStyle);
59 | mDragHelper = ViewDragHelper.create(this, 1f, new DragHelperCallback());
60 | TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.DrawerLayout, defStyle, 0 );
61 | int handleId = a.getResourceId( R.styleable.DrawerLayout_handle, 0 );
62 | if ( handleId == 0 ) { throw new IllegalArgumentException( "The handle attribute is required and must refer "
63 | + "to a valid child." ); }
64 |
65 | int contentId = a.getResourceId( R.styleable.DrawerLayout_content, 0 );
66 | if ( contentId == 0 ) { throw new IllegalArgumentException( "The content attribute is required and must refer "
67 | + "to a valid child." ); }
68 |
69 | if ( handleId == contentId ) { throw new IllegalArgumentException( "The content and handle attributes must refer "
70 | + "to different children." ); }
71 | mHandleId = handleId;
72 | mContentId = contentId;
73 | mdirection = a.getInt( R.styleable.DrawerLayout_direction, ORIENTATION_BOTTOM );
74 | a.recycle();
75 | }
76 |
77 | @Override
78 | protected void onFinishInflate() {
79 | mDescView = findViewById(mHandleId);
80 | content = findViewById(mContentId);
81 | }
82 |
83 | /**
84 | * 显示最大化,及View滑到原始位置
85 | */
86 | public void close() {
87 | smoothSlideTo(0f);
88 | }
89 |
90 | /**
91 | * 显示最小化,及View滑出屏幕
92 | */
93 | public void open() {
94 | smoothSlideTo(1f);
95 | }
96 |
97 | /**
98 | * 滑动试图,1f则为滑出屏幕,0f则滑到原始位置,目前为横向滑
99 | */
100 | boolean smoothSlideTo(float slideOffset) {
101 | final int topBound = getPaddingTop();
102 | int y = (int) (topBound + slideOffset * mDragRange);
103 |
104 | if (mDragHelper.smoothSlideViewTo(mDescView, mDescView.getLeft(), y)) {
105 | ViewCompat.postInvalidateOnAnimation(this);
106 | return true;
107 | }
108 | return false;
109 | }
110 |
111 | private class DragHelperCallback extends ViewDragHelper.Callback {
112 |
113 | /**
114 | * 确定当前子view是否可拖动,
115 | */
116 | @Override
117 | public boolean tryCaptureView(View child, int pointerId) {
118 | return child == mDescView;
119 | }
120 |
121 | /**
122 | * 该方法在子view位置发生改变时都会被调用,可以在这个方法中做一些拖动过程中渐变的动画等操作,left距离左边的偏移量
123 | */
124 | @Override
125 | public void onViewPositionChanged(View changedView, int left, int top,
126 | int dx, int dy) {
127 | switch (mdirection) {
128 | case ORIENTATION_LEFT:
129 | break;
130 | case ORIENTATION_RIGHT:
131 | break;
132 | case ORIENTATION_TOP:
133 | case ORIENTATION_BOTTOM:
134 | mDragOffset = (float) top / mDragRange;
135 | mDescView.setPivotY(mDescView.getHeight());
136 | break;
137 | }
138 |
139 | // mDescView.setAlpha(1 - mDragOffset);
140 |
141 | invalidate();
142 | }
143 |
144 | /**
145 | * 该方法在手势拖动释放的时候被调用,可以在这里设置子View预期到达的位置,
146 | * 如果人为的手势拖动没有到达预期位置,我们可以让子View在人为的拖动结束后,再自动关的滑动到指定位置
147 | *
148 | * @xvel为X轴的拖动速度正的为向右,0代表滑动停止后一段时间后,释放手指
149 | * @yvel为Y轴拖动速度正的为向下
150 | */
151 | @Override
152 | public void onViewReleased(View releasedChild, float xvel, float yvel) {
153 | int top = getPaddingTop();
154 | switch (mdirection) {
155 | case ORIENTATION_LEFT:
156 | break;
157 | case ORIENTATION_RIGHT:
158 | break;
159 | case ORIENTATION_TOP:
160 | case ORIENTATION_BOTTOM:
161 | // 如果方向向右,或者停止滑动却拖动便宜大于可滑动的一半,则滑动总范围,及整个View滑出屏幕
162 | // 如果这句话没执行,则代表滑到原始位置。
163 | if (yvel > 0 || (yvel == 0 && mDragOffset > 0.5f)) {
164 | top += mDragRange;
165 | }
166 | if (top == 0) {
167 | if (mOnDrawerStatusListener != null)
168 | mOnDrawerStatusListener.onStatus(false);
169 | } else {
170 | if (mOnDrawerStatusListener != null)
171 | mOnDrawerStatusListener.onStatus(true);
172 | }
173 | mDragHelper.settleCapturedViewAt(0, top);
174 | break;
175 | }
176 | invalidate();
177 | }
178 |
179 | /**
180 | * 从字面意思就可以看出这是一个获取边界的方法
181 | */
182 | @Override
183 | public int getViewVerticalDragRange(View child) {
184 | return mDragRange;
185 | }
186 |
187 | /** 设置滑动边界为content的高度 */
188 | @Override
189 | public int clampViewPositionVertical(View child, int top, int dy) {
190 | final int topBound = getPaddingTop();
191 | final int bottomBound = content.getHeight();
192 |
193 | final int newTop = Math.min(Math.max(top, topBound), bottomBound);
194 |
195 | return newTop;
196 | }
197 | /**
198 | * 此方法是用来控制水平方向移动的范围,每次调用
199 | * 拿到当前的left值跟DragLayout的根布局的paddingleft值做比较,取两者中大的值
200 | * ,这样做是为了防止子view左边滑出根布局的左边界。 拿left和padding
201 | * left中的较大值跟可滑动范围的右边界(根布局宽度减去子view的宽度)作比较,取较小值,这样做是为了防止子view右边滑出根布局右边界。
202 | */
203 | // @Override
204 | // public int clampViewPositionHorizontal(View child, int left, int dx)
205 | // {
206 | // final int leftBound = getPaddingLeft();
207 | // final int rightBound = getWidth() - 0;
208 | //
209 | // final int newLeft = Math.min(Math.max(left, leftBound), rightBound);
210 | //
211 | // return newLeft;
212 | // }
213 | }
214 |
215 | @Override
216 | public void computeScroll() {
217 | if (mDragHelper.continueSettling(true)) {
218 | ViewCompat.postInvalidateOnAnimation(this);
219 | }
220 | }
221 |
222 | @Override
223 | public boolean onInterceptTouchEvent(MotionEvent ev) {
224 | final int action = MotionEventCompat.getActionMasked(ev);
225 | if (action == MotionEvent.ACTION_CANCEL
226 | || action == MotionEvent.ACTION_UP) {
227 | mDragHelper.cancel();
228 | return false;
229 | }
230 | return mDragHelper.shouldInterceptTouchEvent(ev);
231 | }
232 |
233 | @Override
234 | public boolean onTouchEvent(MotionEvent ev) {
235 | if (!isDrawer) {
236 | return false;
237 | } else {
238 | mDragHelper.processTouchEvent(ev);
239 | return true;
240 | }
241 |
242 | }
243 |
244 | @Override
245 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
246 | measureChildren(widthMeasureSpec, heightMeasureSpec);
247 |
248 | int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
249 | int maxHeight =MeasureSpec.getSize(widthMeasureSpec);
250 | switch (mdirection) {
251 | case ORIENTATION_LEFT:
252 | break;
253 | case ORIENTATION_RIGHT:
254 | break;
255 | case ORIENTATION_TOP:
256 | case ORIENTATION_BOTTOM:
257 | maxWidth = MeasureSpec.getSize(widthMeasureSpec);
258 | maxHeight = content.getMeasuredHeight()+mDescView.getMeasuredHeight();
259 | break;
260 | }
261 | setMeasuredDimension(
262 | resolveSizeAndState(maxWidth, widthMeasureSpec, 0),
263 | resolveSizeAndState(maxHeight, heightMeasureSpec, 0));
264 | }
265 |
266 | @Override
267 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
268 | // 初始化可拖动范围===整个布局的宽度=整个屏幕宽度
269 | mDragRange = content.getMeasuredHeight();
270 | switch (mdirection) {
271 | case ORIENTATION_LEFT:
272 | break;
273 | case ORIENTATION_RIGHT:
274 | break;
275 | case ORIENTATION_TOP:
276 | int mTop_content=getHeight()-content.getMeasuredHeight();
277 | content.layout(0, mTop_content + 0, r, mTop_content + content.getMeasuredHeight());
278 | int mTop_descView=getHeight()-mDescView.getMeasuredHeight();
279 | mDescView.layout(0, mTop_descView + 0, r,
280 | mTop_descView + mDescView.getMeasuredHeight());
281 | break;
282 | case ORIENTATION_BOTTOM:
283 | content.layout(0, mTop + 0, r, mTop + content.getMeasuredHeight());
284 | mDescView.layout(0, mTop + 0, r,
285 | mTop + mDescView.getMeasuredHeight());
286 | break;
287 | }
288 |
289 | }
290 | }
291 |
--------------------------------------------------------------------------------
/Drawer/.idea/dbnavigator.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 |
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 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
--------------------------------------------------------------------------------
/Drawer/mydrawer/src/main/java/com/yanxuwen/mydrawer/BaseDragLayout.java:
--------------------------------------------------------------------------------
1 | package com.yanxuwen.mydrawer;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.support.annotation.FloatRange;
7 | import android.support.v4.view.ViewCompat;
8 | import android.support.v4.widget.ViewDragHelper;
9 | import android.util.AttributeSet;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import java.lang.reflect.Field;
15 |
16 | public abstract class BaseDragLayout extends ViewGroup {
17 | /**
18 | * 是否可以滑动
19 | */
20 | private boolean isSlideable = true;
21 | /**
22 | * 边缘滑动
23 | */
24 | private boolean isEdgeSlide = true;
25 | /**
26 | * 点击外部取消
27 | */
28 | private boolean isOutside = true;
29 | // /**显示出来的最高比例*/
30 | private float maxShowScale = 1F;
31 | private RecyclerViewImpl mRecyclerViewImpl;
32 |
33 | private boolean isopen;
34 | public int mode = MODE_NULL;
35 | private int drag_left;
36 | private int drag_right;
37 | private int drag_top;
38 | private int drag_bottom;
39 |
40 | //边缘大小
41 | private int mEdgeSize = 30;
42 | //设置事件滑动,最小值,当小于这个值,不触发当前滑动
43 | private int mMoveEventSize = 30;
44 | public final static int MODE_NULL = 0;
45 | public final static int MODE_ALPHA = 100;
46 | public final static int MODE_DRAG_LEFT = 1;
47 | public final static int MODE_DRAG_RIGHT = 2;
48 | public final static int MODE_DRAG_BOTTOM = 3;
49 | public final static int MODE_DRAG_TOP = 4;
50 |
51 | private static final int MIN_DRAWER_MARGIN = 80; // dp
52 | /**
53 | * Minimum velocity that will be detected as a fling
54 | */
55 | private static final int MIN_FLING_VELOCITY = 400; // dips per second
56 |
57 | /**
58 | * drawer离父容器右边的最小外边距
59 | */
60 | private int mMinDrawerMargin;
61 |
62 | private View mDescView;
63 |
64 | private ViewDragHelper mDragHelper;
65 | /**
66 | * drawer显示出来的占自身的百分比
67 | */
68 | private float mLeftMenuOnScreen;
69 |
70 | private int pointerId;
71 |
72 | private Context context;
73 |
74 | private boolean isFullScreen;//是否全屏
75 | private boolean isLiuhai;//是否刘海屏
76 | private int statusHeight;
77 |
78 |
79 | /**
80 | * 该拖动试图的开关状态
81 | */
82 | public interface OnDragViewStatusListener {
83 | /**
84 | * 该拖动试图的开关状态
85 | */
86 | public void onDragViewStatus(boolean isOpen);
87 | }
88 |
89 | ;
90 |
91 | /**
92 | * 该拖动试图的偏移量监听
93 | */
94 | public interface OnDragViewOffsetListener {
95 | /**
96 | * 该拖动试图的偏移量监听 0~maxShowScale
97 | */
98 | public void onDragViewOffset(float Offset);
99 | }
100 |
101 | ;
102 |
103 | public OnDragViewStatusListener mOnDragViewStatusListener;
104 | public OnDragViewOffsetListener mOnDragViewOffsetListener;
105 |
106 | public void setOnDragViewStatusListener(OnDragViewStatusListener l) {
107 | mOnDragViewStatusListener = l;
108 | }
109 |
110 | ;
111 |
112 | public void setOnDragViewOffsetListener(OnDragViewOffsetListener l) {
113 | mOnDragViewOffsetListener = l;
114 | }
115 |
116 | ;
117 |
118 | public void removeOnDragViewStatusListener(OnDragViewStatusListener l) {
119 | mOnDragViewStatusListener = null;
120 | }
121 |
122 | ;
123 |
124 | public void removeOnDragViewOffsetListener(OnDragViewOffsetListener l) {
125 | mOnDragViewOffsetListener = null;
126 | }
127 |
128 | ;
129 |
130 | /**
131 | * 状态监听,开关状态
132 | */
133 | public abstract void onViewStatus(boolean isOpen);
134 |
135 | /**
136 | * 偏移量监听
137 | */
138 | public abstract void onViewOffset(float mOffset);
139 |
140 | public abstract void initView();
141 |
142 | private void setContentView(View mDescView) {
143 | mDescView.setClickable(true);
144 | this.mDescView = mDescView;
145 | }
146 |
147 | public View getContentView() {
148 | switch (getMode()) {
149 | case MODE_DRAG_LEFT:
150 | return findViewById(drag_left);
151 | case MODE_DRAG_RIGHT:
152 | return findViewById(drag_right);
153 | case MODE_DRAG_TOP:
154 | return findViewById(drag_top);
155 | case MODE_DRAG_BOTTOM:
156 | return findViewById(drag_bottom);
157 |
158 | }
159 | return this;
160 | }
161 |
162 | public BaseDragLayout(Context context) {
163 | this(context, null);
164 | }
165 |
166 | public BaseDragLayout(Context context, AttributeSet attrs) {
167 | this(context, attrs, 0);
168 | }
169 |
170 | public BaseDragLayout(Context context, AttributeSet attrs, int defStyleAttr) {
171 | super(context, attrs, defStyleAttr);
172 | this.context = context;
173 | try {
174 | statusHeight = NotchScreenUtils.getStatusHeight(context);
175 | isLiuhai = NotchScreenUtils.hasNotchScreen((Activity) context);
176 | } catch (Exception e) {
177 | e.printStackTrace();
178 | }
179 | float density = getResources().getDisplayMetrics().density;
180 | float minVel = MIN_FLING_VELOCITY * density; //1200
181 | mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
182 | TypedArray a = context.obtainStyledAttributes(attrs,
183 | R.styleable.DragLayout);
184 | drag_left = a.getResourceId(R.styleable.DragLayout_drag_left, 0);
185 | drag_right = a.getResourceId(R.styleable.DragLayout_drag_right, 0);
186 | drag_top = a.getResourceId(R.styleable.DragLayout_drag_top, 0);
187 | drag_bottom = a.getResourceId(R.styleable.DragLayout_drag_bottom, 0);
188 |
189 | a.recycle();
190 | mDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
191 | @Override
192 | public boolean tryCaptureView(View child, int pointerId) {
193 | //捕获该view
194 | // return child == mDragView || child == mAutoBackView;
195 | return child.getId() == drag_left || child.getId() == drag_right || child.getId() == drag_top || child.getId() == drag_bottom;
196 | }
197 |
198 | @Override
199 | public int clampViewPositionHorizontal(View child, int left, int dx) {
200 |
201 | if (getMode() != MODE_DRAG_LEFT && getMode() != MODE_DRAG_RIGHT && getMode() != MODE_ALPHA)
202 | return 0;
203 | final int leftBound = 0;
204 | final int rightBound = getWidth() - 0;
205 |
206 |
207 | final int newLeft = Math.max(Math.min(left, leftBound), -child.getWidth());
208 |
209 | final int newRight = Math.max(Math.min(left, rightBound), rightBound - child.getWidth());
210 |
211 |
212 | return (getMode() == MODE_DRAG_LEFT || getMode() == MODE_ALPHA) ? newLeft : newRight;
213 | }
214 |
215 | @Override
216 | public int clampViewPositionVertical(View child, int top, int dy) {
217 |
218 |
219 | if (getMode() != MODE_DRAG_BOTTOM && getMode() != MODE_DRAG_TOP) return 0;
220 | final int topBound = 0;
221 | final int bottomBound = getHeight() - 0;
222 |
223 | final int newTop = Math.max(Math.min(top, topBound), -child.getHeight());
224 |
225 | final int newBottom = Math.max(Math.min(top, bottomBound), bottomBound - child.getHeight());
226 |
227 |
228 | return (getMode() == MODE_DRAG_TOP) ? newTop : newBottom;
229 | }
230 |
231 | //手指释放的时候回调
232 | @Override
233 | public void onViewReleased(View releasedChild, float xvel, float yvel) {
234 | int childWidth = releasedChild.getWidth();
235 | int childHeight = releasedChild.getHeight();
236 |
237 | switch (getMode()) {
238 | case MODE_ALPHA:
239 | case MODE_DRAG_LEFT:
240 | //0~1f,关到开
241 | float offset_left = (childWidth + releasedChild.getLeft()) * 1.0f / childWidth;
242 | int openLeft = (int) (-(1 - maxShowScale) * childWidth);
243 | mDragHelper.settleCapturedViewAt(xvel > 0 || (xvel == 0 && offset_left > 0.5f * maxShowScale) ? openLeft : -childWidth,
244 | releasedChild.getTop());
245 | invalidate();
246 | break;
247 | case MODE_DRAG_RIGHT:
248 |
249 | //0~1,关到开
250 | float offset_right = (getWidth() - releasedChild.getLeft()) * 1.0f / childWidth;
251 | int openRight = (int) (getWidth() - (maxShowScale) * childWidth);
252 | mDragHelper.settleCapturedViewAt(xvel < 0 || (xvel == 0 && offset_right > 0.5f * maxShowScale) ? openRight : getWidth(),
253 | releasedChild.getTop());
254 | invalidate();
255 | break;
256 | case MODE_DRAG_TOP:
257 | //0~1f,关到开
258 | float offset_top = (childHeight + releasedChild.getTop()) * 1.0f / childHeight;
259 | int openTop = (int) (-(1 - maxShowScale) * childHeight);
260 | mDragHelper.settleCapturedViewAt(releasedChild.getLeft(),
261 | yvel > 0 || (yvel == 0 && offset_top > 0.5f * maxShowScale) ? openTop : -childHeight);
262 | invalidate();
263 | break;
264 | case MODE_DRAG_BOTTOM:
265 | //0~1,关到开
266 | float offset_bottom = (getHeight() - releasedChild.getTop()) * 1.0f / childHeight;
267 | int openBottom = (int) (getHeight() - (maxShowScale) * childHeight);
268 | mDragHelper.settleCapturedViewAt(releasedChild.getLeft(),
269 |
270 | yvel < 0 || (yvel == 0 && offset_bottom > 0.5f * maxShowScale) ? openBottom : getHeight());
271 | invalidate();
272 | break;
273 |
274 | }
275 | }
276 |
277 | //在边界拖动时回调
278 | @Override
279 | public void onEdgeDragStarted(int edgeFlags, int pointerId) {
280 | BaseDragLayout.this.pointerId = pointerId;
281 | if (isEdgeSlide()) {
282 | // mDragHelper.captureChildView(mDescView, pointerId);
283 | }
284 | }
285 |
286 | @Override
287 | public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
288 | int childWidth = changedView.getWidth();
289 | int childHeight = changedView.getHeight();
290 |
291 | float offset = 0;
292 | switch (getMode()) {
293 | case MODE_DRAG_LEFT:
294 | offset = (float) (childWidth + left) / childWidth;
295 | break;
296 | case MODE_DRAG_RIGHT:
297 | offset = (float) (getWidth() - left) / childWidth;
298 |
299 | break;
300 | case MODE_DRAG_TOP:
301 | offset = (float) (childHeight + top) / childHeight;
302 |
303 | break;
304 | case MODE_DRAG_BOTTOM:
305 | offset = (float) (getHeight() - top) / childHeight;
306 | break;
307 | }
308 | changedView.setVisibility(offset == 0 ? View.INVISIBLE : View.VISIBLE);
309 | mLeftMenuOnScreen = offset;
310 | onViewOffset(offset);
311 | if (mOnDragViewOffsetListener != null)
312 | mOnDragViewOffsetListener.onDragViewOffset(offset);
313 | if (offset == 0) {
314 | setMode(MODE_NULL);
315 | isopen = false;
316 | onViewStatus(false);
317 | if (mOnDragViewStatusListener != null)
318 | mOnDragViewStatusListener.onDragViewStatus(false);
319 | } else if (offset == 1) {
320 | isopen = true;
321 | onViewStatus(true);
322 | if (mOnDragViewStatusListener != null)
323 | mOnDragViewStatusListener.onDragViewStatus(true);
324 | }
325 | invalidate();
326 | }
327 |
328 | @Override
329 | public int getViewHorizontalDragRange(View child) {
330 | if (!getSlideable()) return 0;
331 | switch (getMode()) {
332 | case MODE_DRAG_LEFT:
333 | case MODE_DRAG_RIGHT:
334 | return getContentView() == child ? child.getWidth() : 0;
335 | case MODE_DRAG_TOP:
336 | case MODE_DRAG_BOTTOM:
337 | return getContentView() == child ? child.getHeight() : 0;
338 | }
339 | return getContentView() == child ? child.getWidth() : 0;
340 |
341 | }
342 |
343 | });
344 | mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT | ViewDragHelper.EDGE_RIGHT | ViewDragHelper.EDGE_BOTTOM | ViewDragHelper.EDGE_TOP);
345 | mDragHelper.setMinVelocity(minVel);
346 | }
347 |
348 | @Override
349 | public void computeScroll() {
350 | if (mDragHelper.continueSettling(true)) {
351 | invalidate();
352 | }
353 | }
354 |
355 | @Override
356 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
357 | measureChildren(widthMeasureSpec, heightMeasureSpec);
358 | int childCount = getChildCount();
359 | if (childCount > 0) {
360 | for (int i = 0; i < childCount; i++) {
361 | View childView = getChildAt(i);
362 | if (drag_left == childView.getId()
363 | || drag_right == childView.getId()
364 | || drag_bottom == childView.getId()
365 | || drag_top == childView.getId()) {
366 | int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
367 | int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
368 |
369 | setMeasuredDimension(
370 | resolveSizeAndState(maxWidth, widthMeasureSpec, 0),
371 | resolveSizeAndState(maxHeight, heightMeasureSpec, 0));
372 |
373 | } else {
374 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
375 |
376 | }
377 | }
378 | }
379 | }
380 |
381 | private boolean initLeft;
382 | private boolean initRight;
383 | private boolean initTop;
384 | private boolean initBottom;
385 | private boolean isFirstChildContent = true;
386 |
387 |
388 | @Override
389 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
390 | int childCount = getChildCount();
391 | if (childCount > 0) {
392 | for (int i = 0; i < childCount; i++) {
393 | View childView = getChildAt(i);
394 | if (drag_left == childView.getId()
395 | || drag_right == childView.getId()
396 | || drag_bottom == childView.getId()
397 | || drag_top == childView.getId()) {
398 | final int menuWidth = childView.getMeasuredWidth();
399 | final int menuHeight = childView.getMeasuredHeight();
400 | int childLeft;
401 | int childTop;
402 | if (drag_left == childView.getId() && !initLeft) {
403 | initLeft = true;
404 | childLeft = -menuWidth + (int) (menuWidth * mLeftMenuOnScreen);
405 | childView.layout(childLeft, 0, childLeft + menuWidth,
406 | menuHeight);
407 | } else if (drag_right == childView.getId() && !initRight) {
408 | initRight = true;
409 | childLeft = getWidth() - (int) (menuWidth * mLeftMenuOnScreen);
410 | childView.layout(childLeft, 0, childLeft + menuWidth,
411 | menuHeight);
412 | } else if (drag_top == childView.getId() && !initTop) {
413 | initTop = true;
414 | childTop = -menuHeight + (int) (menuHeight * mLeftMenuOnScreen);
415 | childView.layout(0, childTop, menuWidth,
416 | childTop + menuHeight);
417 | } else if (drag_bottom == childView.getId() && !initBottom) {
418 | initBottom = true;
419 | childTop = getHeight() - (int) (menuHeight * mLeftMenuOnScreen);
420 | childView.layout(0, childTop, menuWidth,
421 | childTop + menuHeight);
422 | } else {
423 | childView.layout(childView.getLeft(), childView.getTop(), childView.getRight(), childView.getBottom());
424 | }
425 | childView.setClickable(true);
426 | } else {
427 | if (isFirstChildContent) {
428 | isFirstChildContent = false;
429 | setContentView(childView);
430 | childView.setClickable(true);
431 | }
432 | childView.layout(l, t, r, b);
433 | }
434 | }
435 | }
436 |
437 | }
438 |
439 | public void close(int mode) {
440 | mLeftMenuOnScreen = 0.f;
441 | smoothSlideTo(mLeftMenuOnScreen, mode);
442 | }
443 |
444 | public void close() {
445 | mLeftMenuOnScreen = 0.f;
446 | smoothSlideTo(mLeftMenuOnScreen, getMode());
447 | }
448 |
449 | public void open(int mode) {
450 | mLeftMenuOnScreen = maxShowScale;
451 | smoothSlideTo(mLeftMenuOnScreen, mode);
452 | }
453 |
454 | /**
455 | * 如果只有设置一个方向的话,则不用传递类型
456 | * 如果设置多个方向的话,则默认打开左边
457 | */
458 | public void open() {
459 | if (drag_left != 0) {
460 | open(MODE_DRAG_LEFT);
461 | } else if (drag_right != 0) {
462 | open(MODE_DRAG_RIGHT);
463 | } else if (drag_top != 0) {
464 | open(MODE_DRAG_TOP);
465 | } else if (drag_bottom != 0) {
466 | open(MODE_DRAG_BOTTOM);
467 | }
468 | }
469 |
470 | /**
471 | * 滑动试图,1f则为滑出屏幕,0f则滑到原始位置,目前为横向滑
472 | */
473 | private boolean smoothSlideTo(float slideOffset, int mode) {
474 | int childWidth = getContentView().getWidth();
475 | int childHeight = getContentView().getHeight();
476 |
477 | int x = 0;
478 | int y = 0;
479 | setMode(mode);
480 | switch (getMode()) {
481 | case MODE_DRAG_LEFT:
482 | x = (int) ((slideOffset * childWidth) - childWidth);
483 | break;
484 |
485 | case MODE_DRAG_RIGHT:
486 | x = (int) (getWidth() - slideOffset * childWidth);
487 | break;
488 | case MODE_DRAG_TOP:
489 | y = (int) ((slideOffset * childHeight) - childHeight);
490 | break;
491 | case MODE_DRAG_BOTTOM:
492 | y = (int) (getHeight() - slideOffset * childHeight);
493 | break;
494 |
495 | }
496 |
497 | switch (getMode()) {
498 | case MODE_DRAG_RIGHT:
499 | case MODE_DRAG_LEFT:
500 | if (mDragHelper.smoothSlideViewTo(getContentView(), x, getContentView().getTop())) {
501 | ViewCompat.postInvalidateOnAnimation(this);
502 | return true;
503 | }
504 | break;
505 | case MODE_DRAG_BOTTOM:
506 | case MODE_DRAG_TOP:
507 | if (mDragHelper.smoothSlideViewTo(getContentView(), getContentView().getLeft(), y)) {
508 | ViewCompat.postInvalidateOnAnimation(this);
509 | return true;
510 | }
511 | break;
512 |
513 | }
514 | return false;
515 | }
516 |
517 | float downX = 0;
518 | float downY = 0;
519 |
520 | @Override
521 | public boolean onInterceptTouchEvent(MotionEvent ev) {
522 | if (isOutside && !isClickView(getContentView(), ev) && isopen) {
523 | close();
524 | return true;
525 | }
526 | if (getSlideable() || (!getSlideable() && ev.getAction() == MotionEvent.ACTION_UP)) {
527 | mDragHelper.shouldInterceptTouchEvent(ev);
528 | }
529 | //如果在滑动期间则要拦截子类
530 | if (mLeftMenuOnScreen > 0 && mLeftMenuOnScreen < 1) {
531 | return true;
532 | }
533 | if (ev.getAction() == MotionEvent.ACTION_DOWN) {
534 | downX = ev.getX();
535 | downY = ev.getY();
536 | } else if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
537 | } else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
538 | //拦截抽屉外的内容
539 | //如果是其他控件则超过mMoveEventSize,则拦截,拦截
540 | if (!isopen && getMode() == MODE_NULL) {
541 | if ((ev.getX() - downX) > mMoveEventSize && drag_left != 0) {
542 | setMode(MODE_DRAG_LEFT);
543 | mDragHelper.captureChildView(getContentView(), pointerId);
544 | return true;
545 | } else if ((downX - ev.getX()) > mMoveEventSize && drag_right != 0) {
546 | setMode(MODE_DRAG_RIGHT);
547 | mDragHelper.captureChildView(getContentView(), pointerId);
548 | return true;
549 | } else if ((ev.getY() - downY) > mMoveEventSize && drag_top != 0) {
550 | setMode(MODE_DRAG_TOP);
551 | mDragHelper.captureChildView(getContentView(), pointerId);
552 | return true;
553 | } else if ((downY - ev.getY()) > mMoveEventSize && drag_bottom != 0) {
554 | setMode(MODE_DRAG_BOTTOM);
555 | mDragHelper.captureChildView(getContentView(), pointerId);
556 | return true;
557 | }
558 | } else if (isopen) {
559 | //拦截列表
560 | if (mRecyclerViewImpl != null && isClickView(mRecyclerViewImpl.getRecyclerView(), ev)) {
561 | switch (getMode()) {
562 | //如果mRecyclerView不等于空,则要多久判断isRecyclerView的滚动情况,后续会加上nestedscrollview
563 | case MODE_DRAG_LEFT:
564 | if (!mRecyclerViewImpl.canScrollHorizontally(5) && (downX - ev.getX()) > 5)
565 | return true;
566 | break;
567 | case MODE_DRAG_RIGHT:
568 | if (!mRecyclerViewImpl.canScrollHorizontally(-5) && (ev.getX() - downX) > 5)
569 | return true;
570 | break;
571 | case MODE_DRAG_TOP:
572 | if (!mRecyclerViewImpl.canScrollVertically(-5) && (downY - ev.getY()) > 5)
573 | return true;
574 | break;
575 | case MODE_DRAG_BOTTOM:
576 | if (!mRecyclerViewImpl.canScrollVertically(5) && (ev.getY() - downY) > 5)
577 | return true;
578 | break;
579 | }
580 | } else {
581 | //拦截抽屉内的内容
582 | //如果 打开状态,判断条件要跟上面反方向,则要大于20 则拦截,避免无法抽屉内容,无法点击
583 | if (getMode() == MODE_DRAG_LEFT && (downX - ev.getX()) > 20) {
584 | return true;
585 | } else if (getMode() == MODE_DRAG_RIGHT && (ev.getX() - downX) > 20) {
586 | return true;
587 | } else if (getMode() == MODE_DRAG_TOP && (downY - ev.getY()) > 20) {
588 | return true;
589 | } else if (getMode() == MODE_DRAG_BOTTOM && (ev.getY() - downY) > 20) {
590 | return true;
591 | }
592 | }
593 | }
594 |
595 | }
596 |
597 | return false;
598 | }
599 |
600 | @Override
601 | public boolean onTouchEvent(MotionEvent event) {
602 | processTouchEvent(event);
603 | return true;
604 | }
605 |
606 | private void processTouchEvent(MotionEvent event) {
607 | if (getSlideable() || (!getSlideable() && event.getAction() == MotionEvent.ACTION_UP)) {
608 | mDragHelper.processTouchEvent(event);
609 | }
610 | }
611 |
612 |
613 | @Override
614 | protected void onFinishInflate() {
615 | super.onFinishInflate();
616 | initView();
617 | }
618 |
619 | @Override
620 | protected LayoutParams generateDefaultLayoutParams() {
621 | return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
622 | }
623 |
624 | @Override
625 | protected LayoutParams generateLayoutParams(LayoutParams p) {
626 | return new MarginLayoutParams(p);
627 | }
628 |
629 | @Override
630 | public LayoutParams generateLayoutParams(AttributeSet attrs) {
631 | return new MarginLayoutParams(getContext(), attrs);
632 | }
633 |
634 | public void setMode(int mode) {
635 | this.mode = mode;
636 | }
637 |
638 | public int getMode() {
639 | return mode;
640 | }
641 |
642 | /**
643 | * 判断是否是打开状态
644 | */
645 | public boolean isOpen() {
646 | return isopen;
647 | }
648 |
649 | /**
650 | * 是否可以滑动
651 | */
652 | public void setSlideable(boolean isSlideable) {
653 | this.isSlideable = isSlideable;
654 | }
655 |
656 | /**
657 | * 是否可以滑动
658 | */
659 | public boolean getSlideable() {
660 | return isSlideable;
661 | }
662 |
663 | /**
664 | * 是否可以边缘滑动
665 | */
666 | public boolean isEdgeSlide() {
667 | return isEdgeSlide;
668 | }
669 |
670 | /**
671 | * 设置是否可以边缘滑动
672 | */
673 | public void setEdgeSlide(boolean edgeSlide) {
674 | isEdgeSlide = edgeSlide;
675 | }
676 |
677 | /**
678 | * 点击外部取消
679 | */
680 | public void setCanceledOnTouchOutside(boolean isOutside) {
681 | this.isOutside = isOutside;
682 | }
683 |
684 | /**
685 | * 点击外部取消
686 | */
687 | public boolean isOutside() {
688 | return isOutside;
689 | }
690 |
691 | public float getMaxShowScale() {
692 | return maxShowScale;
693 | }
694 |
695 | /**
696 | * 显示出来的最高比例
697 | */
698 | private void setMaxShowScale(@FloatRange(from = 0.0, to = 1.0) float maxShowScale) {
699 | this.maxShowScale = maxShowScale;
700 | }
701 |
702 | /**
703 | * 支持RecyclerView的联动,先滑动RecyclerView,然后在滑动该视图
704 | */
705 | public void setRecyclerViewImpl(final RecyclerViewImpl mRecyclerViewImpl) {
706 | this.mRecyclerViewImpl = mRecyclerViewImpl;
707 | }
708 |
709 | /**
710 | * 设置DragHelper 里面的边缘大小
711 | * 目前有问题,暂不开放
712 | */
713 | private void setEdgeSize(int mEdgeSize) {
714 | this.mEdgeSize = mEdgeSize;
715 | Field field = null;
716 | try {
717 | field = mDragHelper.getClass().getDeclaredField("mEdgeSize");
718 | field.setAccessible(true);
719 | field.set(mDragHelper, mEdgeSize);
720 | } catch (Exception e) {
721 | e.printStackTrace();
722 | }
723 | }
724 |
725 | /**
726 | * 设置事件滑动,最小值,当小于这个值,不触发当前滑动
727 | */
728 | public void setMoveEventSize(int mMoveEventSize) {
729 | this.mMoveEventSize = mMoveEventSize;
730 | }
731 |
732 | /**
733 | * 是否点击到当前View
734 | */
735 | private boolean isClickView(View v, MotionEvent event) {
736 | if (v != null) {
737 | int[] leftTop = {0, 0};
738 | //获取输入框当前的location位置
739 | v.getLocationInWindow(leftTop);
740 | int left = v.getLeft();
741 | int top = v.getTop();
742 | int bottom = v.getBottom();
743 | int right = v.getRight();
744 | float rawY = event.getRawY();
745 | //是否全屏且刘海屏
746 | if (isFullScreen && isLiuhai) {
747 | rawY -= statusHeight;
748 | }
749 | if (event.getRawX() >= left && event.getRawX() <= right
750 | && rawY >= top && rawY <= bottom) {
751 | // 点击的是输入框区域,保留点击EditText的事件
752 | return true;
753 | } else {
754 | return false;
755 | }
756 | }
757 | return true;
758 | }
759 |
760 | /**
761 | * 是否全屏
762 | */
763 | public void setFullScreen(boolean isFullScreen) {
764 | this.isFullScreen = isFullScreen;
765 | }
766 | }
767 |
--------------------------------------------------------------------------------