diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdbe9a6 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +:running:HorizontalRefreshLayout-Android:running: +============ + +开发者使用 HorizontalRefreshLayout-Android 可以对RecycView、Listview、ScrollView等控件实现左右刷新 + +##  APK下载 +[Download](https://github.com/linuxjava/HorizontalRefreshLayout/raw/master/apk/app-debug.apk) +##  Demo使用 +运行demo需删除gradle.properties中的代理 +```xml +systemProp.http.proxyHost=dev-proxy.oa.com +systemProp.http.proxyPort=8080 +systemProp.https.proxyHost=dev-proxy.oa.com +systemProp.https.proxyPort=8080 +``` +## Gradle配置 +compile 'xiao.free.horizontalrefreshlayout:lib:v0.1.2' +## XML配置 +```xml + + + + + +``` +## Java代码 +```java +refreshLayout = (HorizontalRefreshLayout) findViewById(R.id.refresh); +refreshLayout.setRefreshCallback(this); +refreshLayout.setRefreshHeader(new LoadingRefreshHeader(this), HorizontalRefreshLayout.LEFT); +refreshLayout.setRefreshHeader(new LoadingRefreshHeader(this), HorizontalRefreshLayout.RIGHT); +``` +通过setRefreshHeader方法可以设置左右刷新头部,库中已支持三种刷新效果,如下图所示: + +![image](https://github.com/linuxjava/HorizontalRefreshLayout/raw/master/gif/1.gif) +![image](https://github.com/linuxjava/HorizontalRefreshLayout/raw/master/gif/2.gif) +![image](https://github.com/linuxjava/HorizontalRefreshLayout/raw/master/gif/3.gif) + +## 自定义Header +可通过实现如下接口实现自定义header +```java +public interface RefreshHeader { + /** + * @param dragPosition HorizontalRefreshLayout.START or HorizontalRefreshLayout.END + */ + void onStart(int dragPosition, View refreshHead); + + /** + * @param distance + */ + void onDragging(float distance, float percent, View refreshHead); + + void onReadyToRelease(View refreshHead); + + @NonNull View getView(ViewGroup container); + + void onRefreshing(View refreshHead); +} +``` +具体可参考lib库中refreshhead目录中的实现 diff --git a/apk/app-debug.apk b/apk/app-debug.apk new file mode 100644 index 0000000..980d443 Binary files /dev/null and b/apk/app-debug.apk differ diff --git a/app/build.gradle b/app/build.gradle index 6813a5c..11b4406 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,6 @@ android { targetSdkVersion ANDROID_BUILD_SDK_VERSION versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -22,5 +21,7 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.github.lsjwzh.RecyclerViewPager:lib:v1.1.2' - compile 'com.github.linuxjava:HorizontalRefreshLayout:f316b4d448' + //compile project(':lib') + compile 'xiao.free.horizontalrefreshlayout:lib:v0.1.2' + //compile 'xiao.free.horizontalrefreshlayout:lib:v1.0.0' } diff --git a/app/src/main/java/com/example/robincxiao/horizontalrefreshlayout/MainActivity.java b/app/src/main/java/com/example/robincxiao/horizontalrefreshlayout/MainActivity.java index 360c831..9694cf4 100644 --- a/app/src/main/java/com/example/robincxiao/horizontalrefreshlayout/MainActivity.java +++ b/app/src/main/java/com/example/robincxiao/horizontalrefreshlayout/MainActivity.java @@ -8,6 +8,8 @@ import xiao.free.horizontalrefreshlayout.HorizontalRefreshLayout; import xiao.free.horizontalrefreshlayout.RefreshCallBack; +import xiao.free.horizontalrefreshlayout.refreshhead.LoadingRefreshHeader; +import xiao.free.horizontalrefreshlayout.refreshhead.MaterialRefreshHeader; import xiao.free.horizontalrefreshlayout.refreshhead.NiceRefreshHeader; public class MainActivity extends AppCompatActivity implements RefreshCallBack { @@ -38,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) { public void OnPageChanged(int oldPosition, int newPosition) { int size = mLayoutAdapter.getItemCount(); if (size > 1 && newPosition == size - 1) { - mLayoutAdapter.getMore(); + //mLayoutAdapter.getMore(); //refreshLayout.startAutoRefresh(HorizontalRefreshLayout.RIGHT); } } diff --git a/build.gradle b/build.gradle index 685c28f..1302520 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:$GRADLE_VERSION" - //classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,6 +19,11 @@ allprojects { maven { url "https://jitpack.io" } jcenter() } + + tasks.withType(Javadoc).all { + enabled = false + options.setEncoding('UTF-8') + } } task clean(type: Delete) { diff --git a/gif/1.gif b/gif/1.gif new file mode 100644 index 0000000..7cccff9 Binary files /dev/null and b/gif/1.gif differ diff --git a/gif/2.gif b/gif/2.gif new file mode 100644 index 0000000..5b7a812 Binary files /dev/null and b/gif/2.gif differ diff --git a/gif/3.gif b/gif/3.gif new file mode 100644 index 0000000..1c41b9e Binary files /dev/null and b/gif/3.gif differ diff --git a/gradle.properties b/gradle.properties index 2eeb3e4..e1adba1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,18 +15,18 @@ org.gradle.jvmargs=-Xmx1536m # 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 -#gradle汾 -GRADLE_VERSION=2.2.0 -#ĿSDK汾 +#gradle版本 +GRADLE_VERSION=2.1.0 +#目标SDK版本 ANDROID_BUILD_TARGET_SDK_VERSION=19 -#SDK汾 +#编译SDK版本 ANDROID_BUILD_SDK_VERSION=23 -#빤߰汾 +#编译工具版本 ANDROID_BUILD_TOOLS_VERSION=23.0.2 -#V7汾 +#V7包版本 SUPPORT_LIBRARY_VERSION=23.4.0 -#˾ +#代理 systemProp.http.proxyHost=dev-proxy.oa.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=dev-proxy.oa.com diff --git a/jcenter-push.gradle b/jcenter-push.gradle new file mode 100644 index 0000000..3297df2 --- /dev/null +++ b/jcenter-push.gradle @@ -0,0 +1,82 @@ +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.github.dcendents.android-maven' + +def siteUrl = "https://github.com/linuxjava/HorizontalRefreshLayout" +def gitUrl = "https://github.com/linuxjava/HorizontalRefreshLayout.git" + +group = 'xiao.free.horizontalrefreshlayout'// library name +version = 'v0.1.2'// version + +install { + repositories.mavenInstaller { + // This generates POM.xml with proper paramters + pom { + project { + packaging 'aar' + + name 'HorizontalRefreshLayout for Android'//添加项目描述 + url siteUrl + + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'guochangxiao' + name 'guochangxiao' + email 'guochangxiao@gmail.com' + } + } + + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + } + } + } + } +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} + +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + + pkg { + repo = "maven" //JCenter上仓储名 + name = "horizontalrefreshlayout" //JCenter上的项目中的packageName + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = ["Apache-2.0"] + publish = true + } +} \ No newline at end of file diff --git a/lib/build.gradle b/lib/build.gradle index 0ba9adf..8793e7b 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -1,12 +1,9 @@ apply plugin: 'com.android.library' -//apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.github.dcendents.android-maven' - -group='com.github.robinxiao' android { compileSdkVersion ANDROID_BUILD_SDK_VERSION as int buildToolsVersion ANDROID_BUILD_TOOLS_VERSION + resourcePrefix "horizontalrefreshlayout_" defaultConfig { minSdkVersion 14 @@ -30,48 +27,8 @@ dependencies { compile 'com.android.support:appcompat-v7:23.4.0' } -/*******************************上传maven配置********************************************/ -//group = 'xiao.free.horizontalrefreshlayout'// library库包名 -//version = '1.0.0'// 版本号 -// -//task generateSourcesJar(type: Jar) { -// from android.sourceSets.main.java.srcDirs -// classifier = 'sources' -//} -// -// -//task generateJavadocs(type: Javadoc) { -// source = android.sourceSets.main.java.srcDirs -// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) //使用android.getBootClasspath关联Android SDK类文件 -//} -// -//task generateJavadocsJar(type: Jar, dependsOn: generateJavadocs) { -// from generateJavadocs.destinationDir -// classifier = 'javadoc' -//} -// -////generateJavadocsJar.dependsOn generateJavadocs -// -//artifacts { -// //archives generateJavadocsJar //原文为generateJavaDocsJar,此处已做矫正,要严格显示大小写 -// archives generateSourcesJar -//} -// -//bintray { -// user ='guochangxiao' //在个人中心的路径里可以找到 -// key ='6dde4115e9586d6a3bb98d8f3c6401b5dfd09ea9' //上述保存的API key -// pkg { -// repo ='maven' //必须设定一个值,这里选择maven -// name ='xiao.free.horizontalrefreshlayout' //必须,包名 -// version { -// name ='1.0.0-first' //版本名称 -// desc ='horizontalrefreshlayout' //版本描述 -// released =new Date() //上传过程中如果此处报错,可以注释掉此句 -// vcsTag ='1.0.0' //版本 -// } -// licenses = ['Apache-2.0'] //开源协议 -// vcsUrl ='https://github.com/linuxjava/HorizontalRefreshLayout.git' //指定项目git地址 -// websiteUrl ='https://github.com/linuxjava/HorizontalRefreshLayout' //项目官网地址 -// } -// configurations = ['archives'] //必须为archives -//} + +apply from: '../jcenter-push.gradle' + + + diff --git a/lib/src/main/java/xiao/free/horizontalrefreshlayout/refreshhead/LoadingRefreshHeader.java b/lib/src/main/java/xiao/free/horizontalrefreshlayout/refreshhead/LoadingRefreshHeader.java index 1a286bf..ff18602 100644 --- a/lib/src/main/java/xiao/free/horizontalrefreshlayout/refreshhead/LoadingRefreshHeader.java +++ b/lib/src/main/java/xiao/free/horizontalrefreshlayout/refreshhead/LoadingRefreshHeader.java @@ -43,13 +43,6 @@ public void onStart(int dragPosition, View refreshHead) { @Override public void onDragging(float distance, float percent, View refreshHead) { staticLoading.setRotation(percent * 360); - if(percent >= 0 && percent <= 0.1){ - staticLoading.setBackgroundResource(R.drawable.ic_loading_1); - }else if(percent > 0.1 && percent <= 0.2){ - staticLoading.setBackgroundResource(R.drawable.ic_loading_2); - }else { - staticLoading.setBackgroundResource(R.drawable.ic_loading_3); - } } @Override diff --git a/lib/src/main/res/layout/common_loading_refresh_header.xml b/lib/src/main/res/layout/common_loading_refresh_header.xml index ca16eeb..e739bfa 100644 --- a/lib/src/main/res/layout/common_loading_refresh_header.xml +++ b/lib/src/main/res/layout/common_loading_refresh_header.xml @@ -1,22 +1,22 @@ + android:layout_width="88dp" + android:layout_height="match_parent"> + android:indeterminate="true" /> + android:indeterminateDrawable="@drawable/spinner" /> \ No newline at end of file diff --git a/lib/src/main/res/layout/material_refresh_header.xml b/lib/src/main/res/layout/material_refresh_header.xml index 37a2f0f..3ce34cb 100644 --- a/lib/src/main/res/layout/material_refresh_header.xml +++ b/lib/src/main/res/layout/material_refresh_header.xml @@ -1,7 +1,6 @@ + android:layout_height="match_parent"> \ No newline at end of file