From a64c9d6828d55c3c4c3576cf6eca25506279050a Mon Sep 17 00:00:00 2001 From: chenjirui <1391621151@qq.com> Date: Thu, 9 Nov 2017 10:24:30 +0800 Subject: [PATCH 1/3] get view by order without id --- gradle.properties | 37 ++++++++++--------- .../swipetoloadlayout/SwipeToLoadLayout.java | 23 ++++++++++++ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1d3591c..010cc25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,19 @@ -# 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 +## Project-wide Gradle settings. +# +# 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: -Xmx1024m -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 +#Thu Nov 09 09:58:11 CST 2017 +systemProp.https.proxyPort=1080 +systemProp.http.proxyHost=127.0.0.1 +systemProp.https.proxyHost=127.0.0.1 +systemProp.http.proxyPort=1080 diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java index 6802d40..eb53706 100644 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -335,6 +335,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"); From e2e071d72f33043e20f910aeb54de05591f279fa Mon Sep 17 00:00:00 2001 From: chenjirui <1391621151@qq.com> Date: Thu, 9 Nov 2017 10:32:06 +0800 Subject: [PATCH 2/3] get view by order without id --- gradle.properties | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 010cc25..55d18ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,18 @@ -## Project-wide Gradle settings. -# +# 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: -Xmx1024m -XX:MaxPermSize=256m +# 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 -#Thu Nov 09 09:58:11 CST 2017 -systemProp.https.proxyPort=1080 -systemProp.http.proxyHost=127.0.0.1 -systemProp.https.proxyHost=127.0.0.1 -systemProp.http.proxyPort=1080 From aa340c88f42f55f72a00f5041ebd5e3080834ef5 Mon Sep 17 00:00:00 2001 From: rui <1391621151@qq.com> Date: Fri, 8 Dec 2017 09:59:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95=20publ?= =?UTF-8?q?ic=20void=20refreshViewIdentity()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 55d18ea..9b6ae2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,4 @@ # 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 +# 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 eb53706..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