Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 02 10:00:37 CST 2015
#Wed Oct 12 10:04:40 GMT+08:00 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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class SwipeToLoadLayout extends ViewGroup {
private View mHeaderView;

private View mTargetView;
private View mTargetViewContainer;

private View mFooterView;

Expand Down Expand Up @@ -334,6 +335,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!
Expand Down Expand Up @@ -365,7 +382,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
Expand Down Expand Up @@ -934,16 +951,17 @@ public void run() {
* @param loadingMore
*/
public void setLoadingMore(boolean loadingMore) {
if (!isLoadMoreEnabled() || mFooterView == null) {
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() {
Expand Down Expand Up @@ -1050,7 +1068,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;
Expand Down Expand Up @@ -1125,7 +1143,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();
}
}
Expand Down