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
34 changes: 17 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ public SwipeToLoadLayout(Context context, AttributeSet attrs, int defStyleAttr)
@Override
protected void onFinishInflate() {
super.onFinishInflate();
refreshViewIdentity();
}

/*
* 根据 id 或者位置判断header target footer
* */
public void refreshViewIdentity(){
final int childNum = getChildCount();
if (childNum == 0) {
// no child return
Expand All @@ -335,6 +342,29 @@ protected void onFinishInflate() {
mHeaderView = findViewById(R.id.swipe_refresh_header);
mTargetView = findViewById(R.id.swipe_target);
mFooterView = findViewById(R.id.swipe_load_more_footer);
if (mTargetView==null){
switch (childNum){
case 1:{
mTargetView=getChildAt(0);
break;
}
case 2:{
if (mFooterView!=null){
mTargetView=getChildAt(0);
}else {
mHeaderView=getChildAt(0);
mTargetView=getChildAt(1);
}
break;
}
case 3:{
mHeaderView=getChildAt(0);
mTargetView=getChildAt(1);
mFooterView=getChildAt(2);
break;
}
}
}
} else {
// more than three children: unsupported!
throw new IllegalStateException("Children num must equal or less than 3");
Expand Down