diff --git a/gradle.properties b/gradle.properties index 1d3591c..9b6ae2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java index 6802d40..3c760cb 100644 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -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 @@ -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");