From 4f6b1a4fe05e3ad59c4a4ea6b2080aa66cf4caa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cgujinjie=E2=80=9D?= Date: Fri, 9 Dec 2016 19:41:38 +0800 Subject: [PATCH 01/12] fix bugs --- build.gradle | 5 +- gradle/wrapper/gradle-wrapper.properties | 4 +- library/build.gradle | 3 +- .../swipetoloadlayout/SwipeToLoadLayout.java | 51 +++++++++++++++++-- 4 files changed, 55 insertions(+), 8 deletions(-) mode change 100644 => 100755 library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java diff --git a/build.gradle b/build.gradle index 03bced9..14b89df 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' - + classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c8c90b9..63fa4ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Sep 02 10:00:37 CST 2015 +#Fri Dec 09 17:31:34 CST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 11b9e50..95a2b76 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.library' - +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.jfrog.bintray' android { compileSdkVersion 24 buildToolsVersion '24.0.1' diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java old mode 100644 new mode 100755 index 9233ab0..1a06ea2 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -140,6 +140,18 @@ public class SwipeToLoadLayout extends ViewGroup { */ private boolean mLoadMoreEnabled = true; + /** + * a switcher whither hiding headerView when refreshing + */ + + private boolean isHideHeaderWhenRefreshing = true; + + /** + * a switcher whither hiding footerView when loadingmore + */ + + private boolean isHideFooterWhenLoadingMore = true; + /** * ATTRIBUTE: * the style default classic @@ -416,7 +428,7 @@ public LayoutParams(ViewGroup.LayoutParams source) { */ @Override protected ViewGroup.LayoutParams generateDefaultLayoutParams() { - return new SwipeToLoadLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + return new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); } /** @@ -424,7 +436,7 @@ protected ViewGroup.LayoutParams generateDefaultLayoutParams() { */ @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { - return new SwipeToLoadLayout.LayoutParams(p); + return new LayoutParams(p); } /** @@ -432,7 +444,7 @@ protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) */ @Override public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { - return new SwipeToLoadLayout.LayoutParams(getContext(), attrs); + return new LayoutParams(getContext(), attrs); } @Override @@ -496,6 +508,19 @@ public boolean onInterceptTouchEvent(MotionEvent event) { if (mActivePointerId == INVALID_POINTER) { return false; } + + //hide headerView when refreshing , it will improve the user experience + if (mHasHeaderView && isRefreshing() && isHideHeaderWhenRefreshing){ + mRefreshCallback.onReset(); + scrollRefreshingToDefault(); + } + + //hide footerView when loadingmore , it will improve the user experience + if (mHasFooterView && isLoadingMore() && isHideFooterWhenLoadingMore){ + mLoadMoreCallback.onReset(); + scrollLoadingMoreToDefault(); + } + float y = getMotionEventY(event, mActivePointerId); float x = getMotionEventX(event, mActivePointerId); final float yInitDiff = y - mInitDownY; @@ -513,6 +538,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) { // intercept the move action event and pass it to SwipeToLoadLayout#onTouchEvent() return true; } + break; case MotionEvent.ACTION_POINTER_UP: { onSecondaryPointerUp(event); @@ -538,6 +564,7 @@ public boolean onTouchEvent(MotionEvent event) { return true; case MotionEvent.ACTION_MOVE: + // take over the ACTION_MOVE event from SwipeToLoadLayout#onInterceptTouchEvent() // if condition is true final float y = getMotionEventY(event, mActivePointerId); @@ -687,6 +714,24 @@ public boolean isLoadingMore() { return STATUS.isLoadingMore(mStatus); } + /** + * a switcher whither hiding headerView when refreshing + * + * @param hideable + */ + public void setHideHeaderWhenRefreshing(boolean hideable) { + this.isHideHeaderWhenRefreshing = hideable; + } + + /** + * a switcher whither hiding footerView when loadingmore + * + * @param hideable + */ + public void setHideFooterWhenLoadingMore(boolean hideable) { + this.isHideFooterWhenLoadingMore = hideable; + } + /** * set refresh header view, the view must at lease be an implement of {@code SwipeRefreshTrigger}. * the view can also implement {@code SwipeTrigger} for more extension functions From c4bdb1afaa9a26aaff74d3925ab9a7f18ff7d364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cgujinjie=E2=80=9D?= Date: Sat, 10 Dec 2016 10:55:08 +0800 Subject: [PATCH 02/12] remove bintray --- app/build.gradle | 8 ++++++-- build.gradle | 4 ++-- gradlew | 0 library/build.gradle | 12 ++++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) mode change 100644 => 100755 gradlew diff --git a/app/build.gradle b/app/build.gradle index 6823ba0..44d987e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.aspsine.swipetoloadlayout" minSdkVersion 10 targetSdkVersion 24 - versionCode 3 - versionName "1.0.3" + versionCode 1 + versionName "0.0.1" } buildTypes { release { @@ -17,6 +17,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + } + repositories { maven { url "https://jitpack.io" } diff --git a/build.gradle b/build.gradle index 14b89df..e7fc6a7 100644 --- a/build.gradle +++ b/build.gradle @@ -6,11 +6,11 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2' + // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } + } allprojects { diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/library/build.gradle b/library/build.gradle index 95a2b76..fa711a8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' + android { compileSdkVersion 24 buildToolsVersion '24.0.1' @@ -8,8 +7,8 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 24 - versionCode 3 - versionName "1.0.3" + versionCode 1 + versionName "0.0.1" } buildTypes { release { @@ -17,6 +16,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + lintOptions { + abortOnError false + checkReleaseBuilds false + } + } dependencies { From a74776e19b5443b8c9fd2c52e9c3b4a5b3673c55 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 11:42:54 +0800 Subject: [PATCH 03/12] Update README.md --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a6f9dda..a64b288 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +First of all, this project is cloned from Aspsine's SwipeToLoadLayout because it update slowly,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout + +If you like this job,we can do it together to make it better and better,please star me or pull your idea!I will merge it quickly as my best! + +【The Difference】 +1、Add a switcher to hide headerView/footView while refreshing/loadingmore. + + [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812) # SwipeToLoadLayout SwipeToLoadLayout is a reusable pull-to-refresh and pull-to-load-more widget. @@ -5,8 +13,6 @@ SwipeToLoadLayout is a reusable pull-to-refresh and pull-to-load-more widget. ##Supported View Theoretically support all kinds of views. -##Demo -[Download](https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/master/art/demo.apk) ##Demo ScreenShot & Video(Youtube) - ListView & GridView @@ -46,7 +52,7 @@ repositories { - Step 2. Add the dependency in the form ``` dependencies { - compile 'com.github.Aspsine:SwipeToLoadLayout:1.0.3' + compile 'com.github.PigFlyy:SwipeToLoadLayout:v0.0.1' } ``` - Step 3. @@ -54,15 +60,14 @@ Look over [Quick Setup](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick- You can find more customized header view and footer view in the demo app. ##Thanks -- Google SwipeRefreshLayout +- Aspsine SwipeToLoadLayout - [liaohuqiu android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh) - [Yalantis Phoenix](https://github.com/Yalantis/Phoenix) ##Contact Me -- Github: github.com/aspsine -- Email: littleximail@gmail.com -- WeiBo: [@Aspsine](http://weibo.com/wetze) -- Linkedin: cn.linkedin.com/in/aspsine +- Github: github.com/PigFlyy +- Email: 1015121748@qq.com + ##License From 51171e4478cc0672857e215d1566e522b53b127d Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 11:47:16 +0800 Subject: [PATCH 04/12] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a64b288..7615f68 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -First of all, this project is cloned from Aspsine's SwipeToLoadLayout because it update slowly,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout +First of all, this project is cloned from Aspsine's SwipeToLoadLayout ,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout -If you like this job,we can do it together to make it better and better,please star me or pull your idea!I will merge it quickly as my best! +I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please star me or pull your idea!I will merge it quickly as my best! 【The Difference】 1、Add a switcher to hide headerView/footView while refreshing/loadingmore. @@ -56,7 +56,7 @@ dependencies { } ``` - Step 3. -Look over [Quick Setup](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) for more details. +Look over [Quick Setup](https://github.com/PigFlyy/SwipeToLoadLayout/wiki/Quick-Setup) for more details. You can find more customized header view and footer view in the demo app. ##Thanks From b0660bed2e421f758528f0e90198d50beba57a55 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 11:57:01 +0800 Subject: [PATCH 05/12] Update README_CN.md --- README_CN.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README_CN.md b/README_CN.md index 1a7c60c..e90bd92 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,3 +1,11 @@ +####【写在前面】 +##这个项目是克隆自 Aspsine的 SwipeToLoadLayout ,我不是这个项目的原作者,如果你想了解更多关于原作品的信息,请访问 ##https://github.com/Aspsine/SwipeToLoadLayout +##我创建这个分支是因为我觉得原作者更新太慢,如果你也喜欢这个作品并且希望它能变得更好,欢迎Star我或者提交你的idea到这个项目,我会尽我最快的速度更新! + + +###【区别】 +##1、添加一个选择器,可以当你上拉刷新或者加载更多时隐藏头布局或者尾布局,而不是一直保持它们。 + [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812) # SwipeToLoadLayout SwipeToLoadLayout是一个可以帮助你实现下拉刷新和加载更多的Layout @@ -5,8 +13,7 @@ SwipeToLoadLayout是一个可以帮助你实现下拉刷新和加载更多的Lay ##支持的View 理论上支持所有的View -##Demo -[Download](https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/master/art/demo.apk) + ##Demo 截图 & 视频(Youku) - ListView & GridView @@ -46,13 +53,13 @@ repositories { - Step 2. 在你的app build.gradle 的 dependencies 中添加依赖 ``` dependencies { - compile 'com.github.Aspsine:SwipeToLoadLayout:1.0.3' + compile 'com.github.PigFlyy:SwipeToLoadLayout:v0.0.1' } ``` -- Step 3. 查看[快速集成文档](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) +- Step 3. 查看[快速集成文档](https://github.com/PigFlyy/SwipeToLoadLayout/wiki/Quick-Setup) ##致谢 -- Google SwipeRefreshLayout +- Aspsine SwipeRefreshLayout - [liaohuqiu android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh) - [Yalantis Phoenix](https://github.com/Yalantis/Phoenix) From b16251a90457143b50181c2b4148c4febd27cf9e Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 11:59:21 +0800 Subject: [PATCH 06/12] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7615f68..4671b3d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ -First of all, this project is cloned from Aspsine's SwipeToLoadLayout ,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout +###【First of all】 +##this project is cloned from Aspsine's SwipeToLoadLayout ,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout -I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please star me or pull your idea!I will merge it quickly as my best! +##I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please ##star me or pull your idea!I will merge it quickly as my best! -【The Difference】 -1、Add a switcher to hide headerView/footView while refreshing/loadingmore. +###【The Difference】 +#1、Add a switcher to hide headerView/footView while refreshing/loadingmore. [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812) From 5d7e4dc7731c1b5c66449e4bde4c660cd72ce135 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 11:59:58 +0800 Subject: [PATCH 07/12] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4671b3d..2cc0a29 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ ##I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please ##star me or pull your idea!I will merge it quickly as my best! ###【The Difference】 -#1、Add a switcher to hide headerView/footView while refreshing/loadingmore. - +# 1、Add a switcher to hide headerView/footView while refreshing/loadingmore,not keep them always! [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812) # SwipeToLoadLayout From f9c476fc7b7a1b3db143099380cb168acb9f3300 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 12:01:20 +0800 Subject: [PATCH 08/12] Update README.md --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2cc0a29..7f117c6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ -###【First of all】 -##this project is cloned from Aspsine's SwipeToLoadLayout ,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout +#【First of all】 + +###this project is cloned from Aspsine's SwipeToLoadLayout ,I'm not the author of it.if you want to know more about it,please visit https://github.com/Aspsine/SwipeToLoadLayout + +###I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please ###star me or pull your idea!I will merge it quickly as my best! + +#【The Difference】 + +### 1、Add a switcher to hide headerView/footView while refreshing/loadingmore,not keep them always! -##I create this branch because I think Aspsine update slowly, If you like this project and want to make it better and better,please ##star me or pull your idea!I will merge it quickly as my best! -###【The Difference】 -# 1、Add a switcher to hide headerView/footView while refreshing/loadingmore,not keep them always! [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812) # SwipeToLoadLayout From 8339701c0369b812e680db9935c47289dbff1a80 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 12:16:41 +0800 Subject: [PATCH 09/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f117c6..dc532ea 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ dependencies { } ``` - Step 3. -Look over [Quick Setup](https://github.com/PigFlyy/SwipeToLoadLayout/wiki/Quick-Setup) for more details. +Look over [Quick Setup](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) for more details. You can find more customized header view and footer view in the demo app. ##Thanks From 9296ba776d31b57003543c065ec55a084749a020 Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Sat, 10 Dec 2016 12:17:01 +0800 Subject: [PATCH 10/12] Update README_CN.md --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index e90bd92..7003000 100644 --- a/README_CN.md +++ b/README_CN.md @@ -56,7 +56,7 @@ dependencies { compile 'com.github.PigFlyy:SwipeToLoadLayout:v0.0.1' } ``` -- Step 3. 查看[快速集成文档](https://github.com/PigFlyy/SwipeToLoadLayout/wiki/Quick-Setup) +- Step 3. 查看[快速集成文档](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) ##致谢 - Aspsine SwipeRefreshLayout From 97a7a8c6365c7519089ced401ada496df3e865de Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Tue, 13 Dec 2016 11:07:58 +0800 Subject: [PATCH 11/12] Update SwipeToLoadLayout.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、SwipeToLoadLayout,TargetView支持被嵌套 2、Fix SwipeToLoadLayout.setLoadingMore(false) invalid on LoadMoreEnable --- .../swipetoloadlayout/SwipeToLoadLayout.java | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java index 1a06ea2..61075fd 100755 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -58,7 +58,9 @@ public class SwipeToLoadLayout extends ViewGroup { private View mHeaderView; private View mTargetView; - + + private View mTargetViewContainer; + private View mFooterView; private int mHeaderHeight; @@ -346,6 +348,22 @@ protected void onFinishInflate() { } else if (0 < childNum && childNum < 4) { mHeaderView = findViewById(R.id.swipe_refresh_header); mTargetView = findViewById(R.id.swipe_target); + try { + + mTargetViewContainer = (View) mTargetView.getParent(); + + if(mTargetViewContainer instanceof SwipeToLoadLayout) { + + mTargetViewContainer = null; + + }else{ + + while(mTargetViewContainer.getParent() != null){ + + if(mTargetViewContainer.getParent() instanceof SwipeToLoadLayout){ + + break; + + } + + mTargetViewContainer = (View) mTargetViewContainer.getParent(); + + } + + } + + } catch (Exception e) { + + e.printStackTrace(); + + mTargetViewContainer = null; + + } mFooterView = findViewById(R.id.swipe_load_more_footer); } else { // more than three children: unsupported! @@ -377,7 +395,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } // target if (mTargetView != null) { - final View targetView = mTargetView; + final View targetView = mTargetViewContainer == null ? mTargetView : mTargetViewContainer; measureChildWithMargins(targetView, widthMeasureSpec, 0, heightMeasureSpec, 0); } // footer @@ -979,16 +997,18 @@ public void run() { * @param loadingMore */ public void setLoadingMore(boolean loadingMore) { - if (!isLoadMoreEnabled() || mFooterView == null) { - return; - } + if (mFooterView == null) { + return; + } this.mAutoLoading = loadingMore; - if (loadingMore) { + if (loadingMore && isLoadMoreEnabled()) { + + mAutoLoading = true; if (STATUS.isStatusDefault(mStatus)) { setStatus(STATUS.STATUS_SWIPING_TO_LOAD_MORE); scrollDefaultToLoadingMore(); } } else { + mAutoLoading = false; if (STATUS.isLoadingMore(mStatus)) { mLoadMoreCallback.onComplete(); postDelayed(new Runnable() { @@ -1095,7 +1115,7 @@ private void layoutChildren() { // layout target if (mTargetView != null) { - final View targetView = mTargetView; + final View targetView = mTargetViewContainer == null ? mTargetView : mTargetViewContainer; MarginLayoutParams lp = (MarginLayoutParams) targetView.getLayoutParams(); final int targetLeft = paddingLeft + lp.leftMargin; final int targetTop; @@ -1170,7 +1190,10 @@ private void layoutChildren() { mFooterView.bringToFront(); } } else if (mStyle == STYLE.BLEW || mStyle == STYLE.SCALE) { - if (mTargetView != null) { + if(mTargetViewContainer != null){ + + mTargetViewContainer.bringToFront(); + + } + + else if (mTargetView != null) { mTargetView.bringToFront(); } } From 4e7ee6d4cee1f01c9b93320c6c86e9419a77265c Mon Sep 17 00:00:00 2001 From: JinJieGu <1015121748@qq.com> Date: Tue, 13 Dec 2016 11:47:34 +0800 Subject: [PATCH 12/12] fix build errors fix build errors --- .../swipetoloadlayout/SwipeToLoadLayout.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java index 61075fd..564ff51 100755 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -58,9 +58,9 @@ public class SwipeToLoadLayout extends ViewGroup { private View mHeaderView; private View mTargetView; - + private View mTargetViewContainer; - + private View mFooterView; private int mHeaderHeight; @@ -348,22 +348,22 @@ protected void onFinishInflate() { } else if (0 < childNum && childNum < 4) { mHeaderView = findViewById(R.id.swipe_refresh_header); mTargetView = findViewById(R.id.swipe_target); - try { - + mTargetViewContainer = (View) mTargetView.getParent(); - + if(mTargetViewContainer instanceof SwipeToLoadLayout) { - + mTargetViewContainer = null; - + }else{ - + while(mTargetViewContainer.getParent() != null){ - + if(mTargetViewContainer.getParent() instanceof SwipeToLoadLayout){ - + break; - + } - + mTargetViewContainer = (View) mTargetViewContainer.getParent(); - + } - + } - + } catch (Exception e) { - + e.printStackTrace(); - + mTargetViewContainer = null; - + } + try { + mTargetViewContainer = (View) mTargetView.getParent(); + if(mTargetViewContainer instanceof SwipeToLoadLayout) { + mTargetViewContainer = null; + }else{ + while(mTargetViewContainer.getParent() != null){ + if(mTargetViewContainer.getParent() instanceof SwipeToLoadLayout){ + break; + } + mTargetViewContainer = (View) mTargetViewContainer.getParent(); + } + } + } catch (Exception e) { + e.printStackTrace(); + mTargetViewContainer = null; + } mFooterView = findViewById(R.id.swipe_load_more_footer); } else { // more than three children: unsupported! @@ -997,18 +997,18 @@ public void run() { * @param loadingMore */ public void setLoadingMore(boolean loadingMore) { - if (mFooterView == null) { - return; - } + if (mFooterView == null) { + return; + } this.mAutoLoading = loadingMore; if (loadingMore && isLoadMoreEnabled()) { - + mAutoLoading = true; + mAutoLoading = true; if (STATUS.isStatusDefault(mStatus)) { setStatus(STATUS.STATUS_SWIPING_TO_LOAD_MORE); scrollDefaultToLoadingMore(); } } else { - mAutoLoading = false; + mAutoLoading = false; if (STATUS.isLoadingMore(mStatus)) { mLoadMoreCallback.onComplete(); postDelayed(new Runnable() { @@ -1115,7 +1115,7 @@ private void layoutChildren() { // layout target if (mTargetView != null) { - final View targetView = mTargetViewContainer == null ? mTargetView : mTargetViewContainer; + final View targetView = mTargetViewContainer == null ? mTargetView : mTargetViewContainer; MarginLayoutParams lp = (MarginLayoutParams) targetView.getLayoutParams(); final int targetLeft = paddingLeft + lp.leftMargin; final int targetTop; @@ -1191,9 +1191,9 @@ private void layoutChildren() { } } else if (mStyle == STYLE.BLEW || mStyle == STYLE.SCALE) { if(mTargetViewContainer != null){ - + mTargetViewContainer.bringToFront(); - + } - + else if (mTargetView != null) { + mTargetViewContainer.bringToFront(); + } + else if (mTargetView != null) { mTargetView.bringToFront(); } }