├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── app ├── .gitignore ├── app-release.apk ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── head_ic.png │ │ │ │ ├── comment_ic.png │ │ │ │ ├── list_head_bg.jpg │ │ │ │ └── rainbow_ic.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── dimens.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── list_head_layout.xml │ │ │ │ └── list_cell_layout.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── sw │ │ │ │ └── library │ │ │ │ └── widget │ │ │ │ └── friendrefreshview │ │ │ │ ├── OnDetectScrollListener.java │ │ │ │ ├── MainActivity.java │ │ │ │ └── FriendRefreshView.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── sw │ │ └── library │ │ └── widget │ │ └── friendrefreshview │ │ └── ApplicationTest.java ├── build.gradle ├── proguard-rules.pro └── app.iml ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── FriendRefreshView.iml ├── gradle.properties ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | FriendRefreshView -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/app-release.apk -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/head_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/drawable/head_ic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/comment_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/drawable/comment_ic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/list_head_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/drawable/list_head_bg.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/rainbow_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/drawable/rainbow_ic.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliouswang/FriendRefreshView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 你的朋友圈 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/sw/library/widget/friendrefreshview/OnDetectScrollListener.java: -------------------------------------------------------------------------------- 1 | package com.sw.library.widget.friendrefreshview; 2 | 3 | /** 4 | * Created by aliouswang on 15/5/8. 5 | */ 6 | public interface OnDetectScrollListener { 7 | 8 | public void onUpScrolling(); 9 | 10 | public void onDownScrolling(); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sw/library/widget/friendrefreshview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sw.library.widget.friendrefreshview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.sw.library.widget.friendrefreshview" 9 | minSdkVersion 15 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:20.+' 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /FriendRefreshView.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/layout/list_head_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 17 | 18 | 25 | 33 | 34 | 42 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_cell_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | 25 | 26 | 35 | 36 | 45 | 46 | 55 | 56 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/sw/library/widget/friendrefreshview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sw.library.widget.friendrefreshview; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.support.v7.app.ActionBarActivity; 6 | import android.view.LayoutInflater; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.BaseAdapter; 12 | 13 | 14 | public class MainActivity extends ActionBarActivity { 15 | 16 | private FriendRefreshView mWrapListView; 17 | private BaseAdapter mListAdapter; 18 | 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | initView(); 25 | } 26 | 27 | private void initView(){ 28 | mListAdapter = new ListAdapter(); 29 | mWrapListView = (FriendRefreshView) findViewById(R.id.wrapview); 30 | mWrapListView.setAdapter(mListAdapter); 31 | mWrapListView.setOnRefreshListener(new FriendRefreshView.OnRefreshListener() { 32 | @Override 33 | public void onRefresh() { 34 | new Handler().postDelayed(new Runnable() { 35 | @Override 36 | public void run() { 37 | mWrapListView.stopRefresh(); 38 | } 39 | }, 2000); 40 | } 41 | }); 42 | } 43 | 44 | 45 | @Override 46 | public boolean onCreateOptionsMenu(Menu menu) { 47 | // Inflate the menu; this adds items to the action bar if it is present. 48 | getMenuInflater().inflate(R.menu.menu_main, menu); 49 | return true; 50 | } 51 | 52 | @Override 53 | public boolean onOptionsItemSelected(MenuItem item) { 54 | int id = item.getItemId(); 55 | if (id == R.id.action_start_refresh) { 56 | mWrapListView.startRefresh(); 57 | return true; 58 | }else if (id == R.id.action_end_refresh) { 59 | mWrapListView.stopRefresh(); 60 | return true; 61 | } 62 | 63 | return super.onOptionsItemSelected(item); 64 | } 65 | 66 | private class ListAdapter extends BaseAdapter { 67 | 68 | public ListAdapter() { 69 | 70 | } 71 | 72 | @Override 73 | public int getCount() { 74 | return 33; 75 | } 76 | 77 | @Override 78 | public Object getItem(int position) { 79 | return position; 80 | } 81 | 82 | @Override 83 | public long getItemId(int position) { 84 | return position; 85 | } 86 | 87 | @Override 88 | public View getView(int position, View convertView, ViewGroup parent) { 89 | if (convertView == null) { 90 | convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.list_cell_layout, null); 91 | } 92 | return convertView; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Abstraction issues 15 | 16 | 17 | Android 18 | 19 | 20 | Android Lint 21 | 22 | 23 | Assignment issues 24 | 25 | 26 | Assignment issuesGroovy 27 | 28 | 29 | Class metrics 30 | 31 | 32 | Class structure 33 | 34 | 35 | Cloning issues 36 | 37 | 38 | Code maturity issues 39 | 40 | 41 | Code style issues 42 | 43 | 44 | Concurrency annotation issues 45 | 46 | 47 | Control FlowGroovy 48 | 49 | 50 | Control flow issues 51 | 52 | 53 | Data flow issues 54 | 55 | 56 | Declaration redundancy 57 | 58 | 59 | DeclarationGroovy 60 | 61 | 62 | Dependency issues 63 | 64 | 65 | Encapsulation issues 66 | 67 | 68 | Error handling 69 | 70 | 71 | Error handlingGroovy 72 | 73 | 74 | GPath inspectionsGroovy 75 | 76 | 77 | General 78 | 79 | 80 | Google Cloud Endpoints 81 | 82 | 83 | Groovy 84 | 85 | 86 | Inheritance issues 87 | 88 | 89 | Initialization issues 90 | 91 | 92 | Internationalization issues 93 | 94 | 95 | J2ME issues 96 | 97 | 98 | JUnit issues 99 | 100 | 101 | Java language level issues 102 | 103 | 104 | Java language level migration aids 105 | 106 | 107 | JavaBeans issues 108 | 109 | 110 | Javadoc issues 111 | 112 | 113 | Logging issues 114 | 115 | 116 | Memory issues 117 | 118 | 119 | Method MetricsGroovy 120 | 121 | 122 | Method metrics 123 | 124 | 125 | Modularization issues 126 | 127 | 128 | Naming ConventionsGroovy 129 | 130 | 131 | Naming conventions 132 | 133 | 134 | Numeric issues 135 | 136 | 137 | OtherGroovy 138 | 139 | 140 | Packaging issues 141 | 142 | 143 | Pattern Validation 144 | 145 | 146 | Performance issues 147 | 148 | 149 | Portability issues 150 | 151 | 152 | Potentially confusing code constructsGroovy 153 | 154 | 155 | Probable bugs 156 | 157 | 158 | Probable bugsGroovy 159 | 160 | 161 | Resource management issues 162 | 163 | 164 | Security issues 165 | 166 | 167 | Serialization issues 168 | 169 | 170 | TestNG 171 | 172 | 173 | Threading issues 174 | 175 | 176 | Threading issuesGroovy 177 | 178 | 179 | Visibility issues 180 | 181 | 182 | XML 183 | 184 | 185 | toString() issues 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/sw/library/widget/friendrefreshview/FriendRefreshView.java: -------------------------------------------------------------------------------- 1 | package com.sw.library.widget.friendrefreshview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.os.Handler; 6 | import android.os.Message; 7 | import android.support.v4.view.MotionEventCompat; 8 | import android.support.v4.view.ViewCompat; 9 | import android.support.v4.widget.ViewDragHelper; 10 | import android.util.AttributeSet; 11 | import android.view.LayoutInflater; 12 | import android.view.MotionEvent; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.AbsListView; 16 | import android.widget.BaseAdapter; 17 | import android.widget.ImageView; 18 | import android.widget.ListView; 19 | 20 | /** 21 | * 仿微信朋友圈列表页下拉刷新控件 22 | * Created by aliouswang on 15/5/8. 23 | */ 24 | public class FriendRefreshView extends ViewGroup implements OnDetectScrollListener{ 25 | 26 | //圆形指示器 27 | private ImageView mRainbowView; 28 | private ListView mContentView; 29 | 30 | //控件宽,高 31 | private int sWidth; 32 | private int sHeight; 33 | 34 | private ViewDragHelper mDragHelper; 35 | 36 | //contentView的当前top属性 37 | private int currentTop; 38 | //listView首个item 39 | private int firstItem; 40 | private boolean bScrollDown = false; 41 | 42 | private boolean bDraging = false; 43 | 44 | //圆形加载指示器最大top 45 | private int rainbowMaxTop = 80; 46 | //圆形加载指示器刷新时的top 47 | private int rainbowStickyTop = 80; 48 | //圆形加载指示器初始top 49 | private int rainbowStartTop = -120; 50 | //圆形加载指示器的半径 51 | private int rainbowRadius = 100; 52 | private int rainbowTop = - 120; 53 | //圆形加载指示器旋转的角度 54 | private int rainbowRotateAngle = 0; 55 | 56 | private boolean bViewHelperSettling = false; 57 | 58 | //刷新接口listener 59 | private OnRefreshListener mRefreshLisenter; 60 | 61 | private AbsListView.OnScrollListener onScrollListener; 62 | private com.sw.library.widget.friendrefreshview.OnDetectScrollListener onDetectScrollListener; 63 | 64 | public enum State { 65 | NORMAL, 66 | REFRESHING, 67 | DRAGING 68 | } 69 | 70 | //控件当前状态 71 | private State mState = State.NORMAL; 72 | 73 | public FriendRefreshView(Context context) { 74 | this(context, null); 75 | } 76 | 77 | public FriendRefreshView(Context context, AttributeSet attrs) { 78 | this(context, attrs, 0); 79 | } 80 | 81 | public FriendRefreshView(Context context, AttributeSet attrs, int defStyleAttr) { 82 | super(context, attrs, defStyleAttr); 83 | initHandler(); 84 | initDragHelper(); 85 | initListView(); 86 | initRainbowView(); 87 | setBackgroundColor(Color.parseColor("#000000")); 88 | onDetectScrollListener = this; 89 | } 90 | 91 | /** 92 | * 初始化handler,当ViewDragHelper释放了mContentView时, 93 | * 我们通过循环发送消息刷新mRainbowView的位置和角度 94 | */ 95 | private void initHandler() { 96 | mHandler = new Handler() { 97 | @Override 98 | public void handleMessage(Message msg) { 99 | super.handleMessage(msg); 100 | switch (msg.what) { 101 | case 0: 102 | if (rainbowTop > rainbowStartTop) { 103 | rainbowTop -= 10; 104 | requestLayout(); 105 | mHandler.sendEmptyMessageDelayed(0, 15); 106 | } 107 | break; 108 | case 1: 109 | if (rainbowTop <= rainbowStickyTop) { 110 | if (rainbowTop < rainbowStickyTop) { 111 | rainbowTop += 10; 112 | if (rainbowTop > rainbowStickyTop) { 113 | rainbowTop = rainbowStickyTop; 114 | } 115 | } 116 | mRainbowView.setRotation(rainbowRotateAngle -= 10); 117 | }else { 118 | mRainbowView.setRotation(rainbowRotateAngle += 10); 119 | } 120 | 121 | requestLayout(); 122 | 123 | mHandler.sendEmptyMessageDelayed(1, 15); 124 | break; 125 | } 126 | } 127 | }; 128 | } 129 | 130 | /** 131 | * 初始化mDragHelper,我们处理拖动的核心类 132 | */ 133 | private void initDragHelper() { 134 | mDragHelper = ViewDragHelper.create(this, new ViewDragHelper.Callback() { 135 | @Override 136 | public boolean tryCaptureView(View view, int i) { 137 | return view == mContentView && !bViewHelperSettling; 138 | } 139 | 140 | @Override 141 | public int clampViewPositionHorizontal(View child, int left, int dx) { 142 | return 0; 143 | } 144 | 145 | @Override 146 | public int clampViewPositionVertical(View child, int top, int dy) { 147 | return top; 148 | } 149 | 150 | @Override 151 | public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { 152 | super.onViewPositionChanged(changedView, left, top, dx, dy); 153 | if (changedView == mContentView) { 154 | int lastContentTop = currentTop; 155 | if (top >= 0) { 156 | currentTop = top; 157 | }else { 158 | top = 0; 159 | } 160 | int lastTop = rainbowTop; 161 | int rTop = top + rainbowStartTop; 162 | if (rTop >= rainbowMaxTop) { 163 | if (!isRefreshing()) { 164 | rainbowRotateAngle += (currentTop - lastContentTop) * 2; 165 | rTop = rainbowMaxTop; 166 | rainbowTop = rTop; 167 | mRainbowView.setRotation(rainbowRotateAngle); 168 | }else { 169 | rTop = rainbowMaxTop; 170 | rainbowTop = rTop; 171 | } 172 | 173 | }else { 174 | if (isRefreshing()) { 175 | rainbowTop = rainbowStickyTop; 176 | }else { 177 | rainbowTop = rTop; 178 | rainbowRotateAngle += (rainbowTop - lastTop) * 3; 179 | mRainbowView.setRotation(rainbowRotateAngle); 180 | } 181 | } 182 | 183 | requestLayout(); 184 | 185 | } 186 | } 187 | 188 | @Override 189 | public void onViewReleased(View releasedChild, float xvel, float yvel) { 190 | super.onViewReleased(releasedChild, xvel, yvel); 191 | mDragHelper.settleCapturedViewAt(0, 0); 192 | ViewCompat.postInvalidateOnAnimation(FriendRefreshView.this); 193 | //如果手势释放时,拖动的距离大于rainbowStickyTop,开始刷新 194 | if (currentTop >= rainbowStickyTop) { 195 | startRefresh(); 196 | } 197 | 198 | } 199 | }); 200 | 201 | 202 | } 203 | 204 | @Override 205 | public void computeScroll() { 206 | super.computeScroll(); 207 | if (mDragHelper.continueSettling(true)) { 208 | ViewCompat.postInvalidateOnAnimation(this); 209 | bViewHelperSettling = true; 210 | }else { 211 | bViewHelperSettling = false; 212 | } 213 | } 214 | 215 | /** 216 | * 我们invoke 方法shouldIntercept来判断是否需要拦截事件, 217 | * 拦截事件是为了将事件传递给mDragHelper来处理,我们这里只有当mContentView滑动到顶部 218 | * 且mContentView没有处于滑动状态时才触发拦截。 219 | * @param ev 220 | * @return 221 | */ 222 | @Override 223 | public boolean onInterceptTouchEvent(MotionEvent ev) { 224 | mDragHelper.shouldInterceptTouchEvent(ev); 225 | return shouldIntercept(); 226 | } 227 | 228 | @Override 229 | public boolean onTouchEvent(MotionEvent event) { 230 | mDragHelper.processTouchEvent(event); 231 | final int action = event.getActionMasked(); 232 | switch (action) { 233 | case MotionEvent.ACTION_DOWN: 234 | break; 235 | case MotionEvent.ACTION_UP: 236 | mLastMotionY = 0; 237 | bDraging = false; 238 | bScrollDown = false; 239 | rainbowRotateAngle = 0; 240 | break; 241 | case MotionEvent.ACTION_MOVE: 242 | int index = MotionEventCompat.getActionIndex(event); 243 | int pointerId = MotionEventCompat.getPointerId(event, index); 244 | if (shouldIntercept()) { 245 | mDragHelper.captureChildView(mContentView, pointerId); 246 | } 247 | break; 248 | } 249 | return true; 250 | } 251 | 252 | /** 253 | * 判断是否需要拦截触摸事件 254 | * @return 255 | */ 256 | private boolean shouldIntercept() { 257 | if (bDraging) return true; 258 | int childCount = mContentView.getChildCount(); 259 | if (childCount > 0) { 260 | View firstChild = mContentView.getChildAt(0); 261 | if (firstChild.getTop() >= 0 262 | && firstItem == 0 && currentTop == 0 263 | && bScrollDown) { 264 | return true; 265 | }else return false; 266 | }else { 267 | return true; 268 | } 269 | } 270 | 271 | /** 272 | * 判断mContentView是否处于顶部 273 | * @return 274 | */ 275 | private boolean checkIsTop() { 276 | int childCount = mContentView.getChildCount(); 277 | if (childCount > 0) { 278 | View firstChild = mContentView.getChildAt(0); 279 | if (firstChild.getTop() >= 0 280 | && firstItem == 0 && currentTop == 0) { 281 | return true; 282 | }else return false; 283 | }else { 284 | return false; 285 | } 286 | } 287 | 288 | private void initRainbowView() { 289 | mRainbowView = new ImageView(getContext()); 290 | mRainbowView.setImageResource(R.drawable.rainbow_ic); 291 | addView(mRainbowView); 292 | } 293 | 294 | /** 295 | * 初始化listView,我们创建了istView for you,所有你要做的 296 | * 就是调用setAdapter,绑定你自定义的adapter 297 | * 298 | */ 299 | private void initListView() { 300 | mContentView = new FriendRefreshListView(getContext()); 301 | View mHeadViw = LayoutInflater.from(getContext()).inflate(R.layout.list_head_layout, null); 302 | mContentView.addHeaderView(mHeadViw); 303 | 304 | this.addView(mContentView); 305 | mContentView.setOnScrollListener(new AbsListView.OnScrollListener() { 306 | 307 | private int oldTop; 308 | private int oldFirstVisibleItem; 309 | 310 | @Override 311 | public void onScrollStateChanged(AbsListView view, int scrollState) { 312 | if (onScrollListener != null) { 313 | onScrollListener.onScrollStateChanged(view, scrollState); 314 | } 315 | } 316 | 317 | @Override 318 | public void onScroll(AbsListView view, int firstVisibleItem, 319 | int visibleItemCount, int totalItemCount) { 320 | firstItem = firstVisibleItem; 321 | if (onScrollListener != null) { 322 | onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); 323 | } 324 | 325 | if (onDetectScrollListener != null) { 326 | onDetectedListScroll(view, firstVisibleItem); 327 | } 328 | } 329 | 330 | private void onDetectedListScroll(AbsListView absListView, int firstVisibleItem) { 331 | View view = absListView.getChildAt(0); 332 | int top = (view == null) ? 0 : view.getTop(); 333 | 334 | if (firstVisibleItem == oldFirstVisibleItem) { 335 | if (top > oldTop) { 336 | onDetectScrollListener.onUpScrolling(); 337 | } else if (top < oldTop) { 338 | onDetectScrollListener.onDownScrolling(); 339 | } 340 | } else { 341 | if (firstVisibleItem < oldFirstVisibleItem) { 342 | onDetectScrollListener.onUpScrolling(); 343 | } else { 344 | onDetectScrollListener.onDownScrolling(); 345 | } 346 | } 347 | 348 | oldTop = top; 349 | oldFirstVisibleItem = firstVisibleItem; 350 | } 351 | 352 | }); 353 | } 354 | 355 | @Override 356 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 357 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 358 | sWidth = MeasureSpec.getSize(widthMeasureSpec); 359 | sHeight = MeasureSpec.getSize(heightMeasureSpec); 360 | measureChildren(widthMeasureSpec, heightMeasureSpec); 361 | LayoutParams contentParams = (LayoutParams) mContentView.getLayoutParams(); 362 | contentParams.left = 0; 363 | contentParams.top = 0; 364 | } 365 | 366 | 367 | @Override 368 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 369 | LayoutParams contentParams = (LayoutParams) mContentView.getLayoutParams(); 370 | mContentView.layout(contentParams.left, currentTop, 371 | contentParams.left + sWidth, currentTop + sHeight); 372 | 373 | mRainbowView.layout(rainbowRadius, rainbowTop, 374 | rainbowRadius * 2 , rainbowTop + rainbowRadius); 375 | } 376 | 377 | @Override 378 | public void onUpScrolling() { 379 | bScrollDown = false; 380 | } 381 | 382 | @Override 383 | public void onDownScrolling() { 384 | bScrollDown = true; 385 | } 386 | 387 | public static class LayoutParams extends ViewGroup.LayoutParams { 388 | 389 | public int left = 0; 390 | public int top = 0; 391 | 392 | public LayoutParams(Context arg0, AttributeSet arg1) { 393 | super(arg0, arg1); 394 | } 395 | 396 | public LayoutParams(int arg0, int arg1) { 397 | super(arg0, arg1); 398 | } 399 | 400 | public LayoutParams(android.view.ViewGroup.LayoutParams arg0) { 401 | super(arg0); 402 | } 403 | 404 | } 405 | 406 | @Override 407 | public android.view.ViewGroup.LayoutParams generateLayoutParams( 408 | AttributeSet attrs) { 409 | return new FriendRefreshView.LayoutParams(getContext(), attrs); 410 | } 411 | 412 | @Override 413 | protected android.view.ViewGroup.LayoutParams generateDefaultLayoutParams() { 414 | return new LayoutParams(LayoutParams.WRAP_CONTENT, 415 | LayoutParams.WRAP_CONTENT); 416 | } 417 | 418 | @Override 419 | protected android.view.ViewGroup.LayoutParams generateLayoutParams( 420 | android.view.ViewGroup.LayoutParams p) { 421 | return new LayoutParams(p); 422 | } 423 | 424 | @Override 425 | protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p) { 426 | return p instanceof FriendRefreshView.LayoutParams; 427 | } 428 | 429 | private float mLastMotionX; 430 | private float mLastMotionY; 431 | 432 | /** 433 | * 对ListView的触摸事件进行判断,是否处于滑动状态 434 | */ 435 | private class FriendRefreshListView extends ListView { 436 | 437 | 438 | 439 | public FriendRefreshListView(Context context) { 440 | this(context, null); 441 | } 442 | 443 | public FriendRefreshListView(Context context, AttributeSet attrs) { 444 | this(context, attrs, 0); 445 | } 446 | 447 | public FriendRefreshListView(Context context, AttributeSet attrs, int defStyleAttr) { 448 | super(context, attrs, defStyleAttr); 449 | setBackgroundColor(Color.parseColor("#ffffff")); 450 | } 451 | 452 | /*当前活动的点Id,有效的点的Id*/ 453 | protected int mActivePointerId = INVALID_POINTER; 454 | 455 | /*无效的点*/ 456 | private static final int INVALID_POINTER = -1; 457 | 458 | @Override 459 | public boolean onTouchEvent(MotionEvent ev) { 460 | final int action = ev.getActionMasked(); 461 | switch (action) { 462 | case MotionEvent.ACTION_DOWN: 463 | int index = MotionEventCompat.getActionIndex(ev); 464 | mActivePointerId = MotionEventCompat.getPointerId(ev, index); 465 | if (mActivePointerId == INVALID_POINTER) 466 | break; 467 | mLastMotionX = ev.getX(); 468 | mLastMotionY = ev.getY(); 469 | break; 470 | 471 | case MotionEvent.ACTION_MOVE: 472 | int indexMove = MotionEventCompat.getActionIndex(ev); 473 | mActivePointerId = MotionEventCompat.getPointerId(ev, indexMove); 474 | 475 | if (mActivePointerId == INVALID_POINTER) { 476 | 477 | }else { 478 | final float y = ev.getY(); 479 | float dy = y - mLastMotionY; 480 | if (checkIsTop() && dy >= 1.0f) { 481 | bScrollDown = true; 482 | bDraging = true; 483 | }else { 484 | bScrollDown = false; 485 | bDraging = false; 486 | } 487 | mLastMotionX = y; 488 | } 489 | break; 490 | 491 | case MotionEvent.ACTION_UP: 492 | mLastMotionY = 0; 493 | break; 494 | } 495 | return super.onTouchEvent(ev); 496 | } 497 | } 498 | 499 | public void setAdapter(BaseAdapter adapter) { 500 | if (mContentView != null) { 501 | mContentView.setAdapter(adapter); 502 | } 503 | } 504 | 505 | public boolean isRefreshing() { 506 | return mState == State.REFRESHING; 507 | } 508 | 509 | 510 | Handler mHandler; 511 | public void startRefresh() { 512 | if (!isRefreshing()) { 513 | mHandler.removeMessages(0); 514 | mHandler.removeMessages(1); 515 | mHandler.sendEmptyMessage(1); 516 | mState = State.REFRESHING; 517 | invokeListner(); 518 | } 519 | 520 | } 521 | 522 | private void invokeListner() { 523 | if (mRefreshLisenter != null) { 524 | mRefreshLisenter.onRefresh(); 525 | } 526 | } 527 | 528 | public void stopRefresh() { 529 | mHandler.removeMessages(1); 530 | mHandler.sendEmptyMessage(0); 531 | mState = State.NORMAL; 532 | } 533 | 534 | public void setOnRefreshListener(OnRefreshListener listener) { 535 | this.mRefreshLisenter = listener; 536 | } 537 | 538 | public interface OnRefreshListener { 539 | public void onRefresh(); 540 | } 541 | } 542 | --------------------------------------------------------------------------------