diff --git a/.gitignore b/.gitignore
index 5edb4ee..081b0e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,42 @@
+# Built application files
+*.apk
+*.ap_
+
+# Files for the Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Idea tool config
+.idea
*.iml
-.gradle
-/local.properties
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-.DS_Store
-/build
-/captures
-.externalNativeBuild
+
+traces.txt
+
+reports/
+
+*.DS_Store
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
deleted file mode 100644
index ae5cdb3..0000000
Binary files a/.idea/caches/build_file_checksums.ser and /dev/null differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 30aa626..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index a6dad1e..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 821cf50..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/appbarlayoutbehavior/build.gradle b/appbarlayoutbehavior/build.gradle
index d16a0ad..1d0a34c 100644
--- a/appbarlayoutbehavior/build.gradle
+++ b/appbarlayoutbehavior/build.gradle
@@ -6,11 +6,10 @@ group='com.github.yuruiyin'
android {
compileSdkVersion 27
-
-
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
+ buildToolsVersion '27.0.3'
versionCode 1
versionName "1.0"
@@ -31,10 +30,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-
- implementation 'com.android.support:appcompat-v7:27.1.1'
- implementation 'com.android.support:design:27.1.1'
}
diff --git a/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java b/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java
index dc93f38..9debb5e 100644
--- a/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java
+++ b/appbarlayoutbehavior/src/main/java/com/yuruiyin/appbarlayoutbehavior/AppBarLayoutBehavior.java
@@ -49,6 +49,42 @@ public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout chil
return super.onInterceptTouchEvent(parent, child, ev);
}
+ /**
+ * 反射获取私有的flingRunnable 属性,考虑support 28以后变量名修改的问题
+ * @return Field
+ * @throws NoSuchFieldException
+ */
+ private Field getFlingRunnableField() throws NoSuchFieldException {
+ try {
+ // support design 27及一下版本
+ Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
+ return headerBehaviorType.getDeclaredField("mFlingRunnable");
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ // 可能是28及以上版本
+ Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass().getSuperclass();
+ return headerBehaviorType.getDeclaredField("flingRunnable");
+ }
+ }
+
+ /**
+ * 反射获取私有的scroller 属性,考虑support 28以后变量名修改的问题
+ * @return Field
+ * @throws NoSuchFieldException
+ */
+ private Field getScrollerField() throws NoSuchFieldException {
+ try {
+ // support design 27及一下版本
+ Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
+ return headerBehaviorType.getDeclaredField("mScroller");
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ // 可能是28及以上版本
+ Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass().getSuperclass();
+ return headerBehaviorType.getDeclaredField("scroller");
+ }
+ }
+
/**
* 停止appbarLayout的fling事件
* @param appBarLayout
@@ -56,9 +92,9 @@ public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout chil
private void stopAppbarLayoutFling(AppBarLayout appBarLayout) {
//通过反射拿到HeaderBehavior中的flingRunnable变量
try {
- Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass();
- Field flingRunnableField = headerBehaviorType.getDeclaredField("mFlingRunnable");
- Field scrollerField = headerBehaviorType.getDeclaredField("mScroller");
+ Class> headerBehaviorType = this.getClass().getSuperclass().getSuperclass().getSuperclass();
+ Field flingRunnableField = getFlingRunnableField();
+ Field scrollerField = getScrollerField();
flingRunnableField.setAccessible(true);
scrollerField.setAccessible(true);
diff --git a/build.gradle b/build.gradle
index 24e67e9..960a85d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -29,3 +29,23 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
+
+ext {
+ compileSdkVersion = 28
+ buildToolsVersion = '28.0.3'
+ minSdkVersion = 15
+ targetSdkVersion = 28
+ androidSupportVersion = "28.0.0"
+}
+
+subprojects {
+ project.configurations.all {
+ resolutionStrategy.eachDependency { details ->
+ if (details.requested.group == 'com.android.support'
+ && !details.requested.name.contains('multidex') ) {
+ details.useVersion androidSupportVersion
+ }
+ }
+ }
+}
+
diff --git a/sample/build.gradle b/sample/build.gradle
index d115179..aca86e8 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,13 +1,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 27
+ compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.yuruiyin.sample"
- minSdkVersion 15
- targetSdkVersion 27
- versionCode 2
- versionName "1.0.1"
+ minSdkVersion rootProject.ext.minSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ targetSdkVersion rootProject.ext.targetSdkVersion
+ versionCode 3
+ versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -25,9 +26,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.android.support:appcompat-v7:27.1.1'
- implementation 'com.android.support:design:27.1.1'
- implementation 'com.android.support.constraint:constraint-layout:1.1.2'
+ implementation "com.android.support:appcompat-v7:$androidSupportVersion"
+ implementation "com.android.support:design:$androidSupportVersion"
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -39,6 +40,8 @@ dependencies {
implementation project(':appbarlayoutbehavior')
-// implementation 'com.github.yuruiyin:AppbarLayoutBehavior:v1.0.0'
+// implementation 'com.github.yuruiyin:AppbarLayoutBehavior:v1.0.1'
}
+
+
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index 398a221..60c38b3 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -19,16 +19,17 @@
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ >
@@ -40,7 +41,8 @@
android:layout_height="@dimen/common_tab_height"
android:layout_gravity="left"
android:background="@color/white"
- android:visibility="visible"/>
+ android:visibility="visible"
+ />
-
-
-
-
-
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ />
\ No newline at end of file