├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── 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
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── sw
│ │ │ └── library
│ │ │ └── widget
│ │ │ └── universalloadingview
│ │ │ └── MainActivity.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── sw
│ │ └── library
│ │ └── widget
│ │ └── universalloadingview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── scopes
│ └── scope_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── loadingview.library
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── attrs.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── sw
│ │ │ └── library
│ │ │ └── widget
│ │ │ └── library
│ │ │ ├── MaterialCircleView.java
│ │ │ └── UniversalLoadingView.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── sw
│ │ └── library
│ │ └── widget
│ │ └── library
│ │ └── ApplicationTest.java
├── build.gradle
├── proguard-rules.pro
└── loadingview.library.iml
├── settings.gradle
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── UniversalLoadingView.iml
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | UniversalLoadingView
--------------------------------------------------------------------------------
/loadingview.library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':loadingview.library'
2 |
--------------------------------------------------------------------------------
/.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/UniversalLoadingView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/loadingview.library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliouswang/UniversalLoadingView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliouswang/UniversalLoadingView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliouswang/UniversalLoadingView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aliouswang/UniversalLoadingView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
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 | UniversalLoadingView
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 |
--------------------------------------------------------------------------------
/loadingview.library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/loadingview.library/src/androidTest/java/com/sw/library/widget/library/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.sw.library.widget.library;
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/androidTest/java/com/sw/library/widget/universalloadingview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.sw.library.widget.universalloadingview;
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 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/loadingview.library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/loadingview.library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 21
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:20.+'
24 | compile 'com.orhanobut:logger:1.8'
25 | }
26 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/loadingview.library/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 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.sw.library.widget.universalloadingview"
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 | compile 'com.android.support:support-v4:20.0.0'
26 | compile project(':loadingview.library')
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/UniversalLoadingView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
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/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
17 |
18 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UniversalLoadingView
2 | An universal loading view for help you
3 | to show a loading progressbar and label
4 | when you do a background task. .
5 |
6 | It is really sample, and it has handle all issues such as,retry load , load falied... etc for you.
7 |
8 | How to Use
9 |
10 |
19 |
20 | Put UniversalLoadingView in your xml files. you can custom the progress bar radius and color, and you can
21 | also set the background is transparent or not when really start loading.
22 |
23 | mLoadingView = (UniversalLoadingView) findViewById(R.id.loadingView);
24 | mLoadingView.setOnReloadListener(new UniversalLoadingView.ReloadListner() {
25 | @Override
26 | public void reload() {
27 | loadImageView();
28 | }
29 | });
30 |
31 | You can set one reload listener to UniversalLoadingView, so that it can retry for you when users click the screen to
32 | reload.
33 |
--------------------------------------------------------------------------------
/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/universalloadingview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sw.library.widget.universalloadingview;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.os.AsyncTask;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.support.v4.widget.SwipeRefreshLayout;
9 | import android.support.v7.app.ActionBarActivity;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.widget.ImageView;
13 |
14 | import com.sw.library.widget.library.UniversalLoadingView;
15 |
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.net.HttpURLConnection;
19 | import java.net.MalformedURLException;
20 | import java.net.URL;
21 |
22 |
23 | public class MainActivity extends ActionBarActivity {
24 | Handler mHandler;
25 | SwipeRefreshLayout refreshLayout;
26 | ImageView mImageView;
27 | UniversalLoadingView mLoadingView;
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_main);
32 | mHandler = new Handler();
33 | refreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh_layout);
34 | refreshLayout.setColorScheme(android.R.color.holo_blue_bright,
35 | android.R.color.holo_green_light, android.R.color.holo_red_light,
36 | android.R.color.holo_orange_light);
37 | refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
38 | @Override
39 | public void onRefresh() {
40 | refreshLayout.setRefreshing(true);
41 | ( new Handler()).postDelayed(new Runnable() {
42 | @Override
43 | public void run() {
44 | refreshLayout.setRefreshing(false);
45 | }
46 | }, 5000);
47 | }
48 | });
49 |
50 | mImageView = (ImageView) findViewById(R.id.imageview);
51 | mLoadingView = (UniversalLoadingView) findViewById(R.id.loadingView);
52 | mLoadingView.setOnReloadListener(new UniversalLoadingView.ReloadListner() {
53 | @Override
54 | public void reload() {
55 | loadImageView();
56 | }
57 | });
58 |
59 | loadImageView();
60 | }
61 |
62 | private void loadImageView() {
63 | new LoadImageTask().execute("http://d.hiphotos.baidu.com/zhidao/pic/item/38dbb6fd5266d016329c0b53952bd40734fa35c7.jpg");
64 |
65 | }
66 |
67 | private class LoadImageTask extends AsyncTask {
68 |
69 | @Override
70 | protected void onPreExecute() {
71 | super.onPreExecute();
72 | mLoadingView.postLoadState(UniversalLoadingView.State.LOADING);
73 | }
74 |
75 | @Override
76 | protected Bitmap doInBackground(String... params) {
77 | try {
78 | URL imageUrl = new URL(params[0]);
79 | HttpURLConnection urlConnection = (HttpURLConnection)imageUrl.openConnection();
80 | InputStream input = urlConnection.getInputStream();
81 | Bitmap bitmap = BitmapFactory.decodeStream(input);
82 | return bitmap;
83 | } catch (MalformedURLException e) {
84 | e.printStackTrace();
85 | } catch (IOException e) {
86 | e.printStackTrace();
87 | } finally {
88 |
89 | }
90 | return null;
91 | }
92 |
93 | @Override
94 | protected void onPostExecute(Bitmap bitmap) {
95 | mImageView.setImageBitmap(bitmap);
96 | mLoadingView.postLoadState(UniversalLoadingView.State.GONE);
97 | super.onPostExecute(bitmap);
98 | }
99 | }
100 |
101 |
102 | @Override
103 | public boolean onCreateOptionsMenu(Menu menu) {
104 | // Inflate the menu; this adds items to the action bar if it is present.
105 | getMenuInflater().inflate(R.menu.menu_main, menu);
106 | return true;
107 | }
108 |
109 | @Override
110 | public boolean onOptionsItemSelected(MenuItem item) {
111 | // Handle action bar item clicks here. The action bar will
112 | // automatically handle clicks on the Home/Up button, so long
113 | // as you specify a parent activity in AndroidManifest.xml.
114 | int id = item.getItemId();
115 |
116 | //noinspection SimplifiableIfStatement
117 | if (id == R.id.action_settings) {
118 | return true;
119 | }
120 |
121 | return super.onOptionsItemSelected(item);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/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 |
196 |
197 |
198 |
199 |
--------------------------------------------------------------------------------
/loadingview.library/src/main/java/com/sw/library/widget/library/MaterialCircleView.java:
--------------------------------------------------------------------------------
1 | package com.sw.library.widget.library;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Bitmap;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.graphics.PorterDuff;
11 | import android.graphics.PorterDuffXfermode;
12 | import android.graphics.RectF;
13 | import android.util.AttributeSet;
14 | import android.util.TypedValue;
15 | import android.view.View;
16 |
17 | /**
18 | * Created by aliouswang on 15/5/6.
19 | */
20 | public class MaterialCircleView extends View {
21 |
22 | private boolean bGradient;
23 |
24 | private int circleColor;
25 | private int circleWidth;
26 | private int radius;
27 |
28 | private Paint mPaint;
29 | private int rotateDelta = 4;
30 | private int curAngle = 0;
31 |
32 | private int minAngle = 0;
33 | private int startAngle = 0;
34 | private int endAngle = 120;
35 |
36 | private int sWidth;
37 | private int sHeight;
38 |
39 | private int halfWidth;
40 | private int halfHeight;
41 |
42 | private int red = 0;
43 | private int green = 0;
44 | private int blue = 255;
45 |
46 | int phase = 0;
47 |
48 |
49 | public MaterialCircleView(Context context) {
50 | this(context, null);
51 | }
52 |
53 | public MaterialCircleView(Context context, AttributeSet attrs) {
54 | this(context, attrs, 0);
55 | }
56 |
57 | public MaterialCircleView(Context context, AttributeSet attrs, int defStyleAttr) {
58 | super(context, attrs, defStyleAttr);
59 |
60 | TypedArray t = null;
61 | try {
62 | t = context.obtainStyledAttributes(attrs, R.styleable.MaterialCircleView,
63 | 0, defStyleAttr);
64 | setbGradient(t.getBoolean(R.styleable.MaterialCircleView_bGradient, true));
65 | circleColor = t.getColor(R.styleable.MaterialCircleView_circleColor,
66 | getResources().getColor(android.R.color.holo_blue_light));
67 | circleWidth = t.getDimensionPixelSize(R.styleable.MaterialCircleView_circleWidth,
68 | 10);
69 | radius = t.getDimensionPixelSize(R.styleable.MaterialCircleView_radius,
70 | 50);
71 | } finally {
72 | if (t != null) {
73 | t.recycle();
74 | }
75 | }
76 |
77 | mPaint = new Paint();
78 | if (isbGradient()) {
79 | mPaint.setColor(Color.rgb(red, green, blue));
80 | }else {
81 | mPaint.setColor(circleColor);
82 | }
83 | mPaint.setAntiAlias(true);
84 | setBackgroundColor(getResources().getColor(android.R.color.transparent));
85 | }
86 |
87 |
88 |
89 | @Override
90 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
91 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
92 |
93 | sWidth = this.getMeasuredWidth();
94 | sHeight = this.getMeasuredHeight();
95 | halfWidth = sWidth / 2;
96 | halfHeight = sHeight / 2;
97 | }
98 |
99 | private int colorDelta = 2;
100 | private void checkPaint() {
101 | if (isbGradient()) {
102 | switch (phase % 5) {
103 | case 0:
104 | green += colorDelta;
105 | if (green > 255) {
106 | green = 255;
107 | phase ++;
108 | }
109 | break;
110 | case 1:
111 | red += colorDelta;
112 | green -= colorDelta;
113 | if (red > 255) {
114 | red = 255;
115 | green = 0;
116 | phase ++;
117 | }
118 | break;
119 | case 2:
120 | blue -= colorDelta;
121 | if (blue < 0) {
122 | blue = 0;
123 | phase ++;
124 | }
125 | break;
126 | case 3:
127 | red -= colorDelta;
128 | green += colorDelta;
129 | if (red < 0) {
130 | red = 0;
131 | green = 255;
132 | phase ++;
133 | }
134 | break;
135 | case 4:
136 | green -= colorDelta;
137 | blue += colorDelta;
138 | if (green < 0) {
139 | green = 0;
140 | blue = 255;
141 | phase ++;
142 | }
143 | break;
144 | }
145 |
146 |
147 | mPaint.setColor(Color.rgb(red, green, blue));
148 | }
149 | }
150 |
151 | @Override
152 | protected void onDraw(Canvas canvas) {
153 | super.onDraw(canvas);
154 | if (startAngle == minAngle) {
155 | endAngle += 6;
156 | }
157 | if (endAngle >= 280 || startAngle > minAngle) {
158 | startAngle += 6;
159 | if(endAngle > 20) {
160 | endAngle -= 6;
161 | }
162 |
163 | }
164 | if (startAngle > minAngle + 280) {
165 | minAngle = startAngle;
166 | startAngle = minAngle;
167 | endAngle = 20;
168 | }
169 |
170 | checkPaint();
171 | canvas.rotate(curAngle += rotateDelta, halfWidth, halfHeight);
172 |
173 | Bitmap bitmap = Bitmap.createBitmap(sWidth, sHeight, Bitmap.Config.ARGB_8888);
174 | Canvas bmpCanvas = new Canvas(bitmap);
175 | bmpCanvas.drawArc(new RectF(0, 0, sWidth, sHeight), startAngle, endAngle, true, mPaint);
176 | Paint transparentPaint = new Paint();
177 | transparentPaint.setAntiAlias(true);
178 | transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
179 | transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
180 | bmpCanvas.drawCircle(halfWidth, halfHeight,
181 | halfWidth - circleWidth, transparentPaint);
182 | canvas.drawBitmap(bitmap, 0, 0, new Paint());
183 |
184 | invalidate();
185 | }
186 |
187 | /**
188 | * Convert Dp to Pixel
189 | */
190 | public static int dpToPx(float dp, Resources resources){
191 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
192 | return (int) px;
193 | }
194 |
195 | /**
196 | * need gradient or not
197 | */
198 | public boolean isbGradient() {
199 | return bGradient;
200 | }
201 |
202 | public void setbGradient(boolean bGradient) {
203 | this.bGradient = bGradient;
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
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 |
95 |
--------------------------------------------------------------------------------
/loadingview.library/loadingview.library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
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 |
95 |
96 |
--------------------------------------------------------------------------------
/loadingview.library/src/main/java/com/sw/library/widget/library/UniversalLoadingView.java:
--------------------------------------------------------------------------------
1 | package com.sw.library.widget.library;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.os.Handler;
7 | import android.util.AttributeSet;
8 | import android.view.Gravity;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 |
14 | /**
15 | * Universal Loading View , it
16 | * Created by aliouswang on 15/5/6.
17 | */
18 | public class UniversalLoadingView extends ViewGroup{
19 |
20 | private static final String LOADING_TIP = "加载中...";
21 | private static final String LOAD_FAILED_TIP = "加载失败\n点击重试";
22 | private static final String LOAD_EMPTY_TIP = "暂无数据";
23 |
24 | private MaterialCircleView materialCircleView;
25 | private TextView mTipTextView;
26 |
27 | private int sWidth;
28 | private int sHeight;
29 |
30 | /**
31 | * need gradient or not
32 | */
33 | private boolean bGradient;
34 |
35 | private int circleColor;
36 | private int circleWidth;
37 | private int radius;
38 |
39 | private boolean bTransparent;
40 | private int alpha;
41 |
42 | private State mLoadState = State.LOADING;
43 |
44 | private Handler mHandler;
45 |
46 | private ReloadListner mReloadListener;
47 |
48 | public boolean isbTransparent() {
49 | return bTransparent;
50 | }
51 |
52 | public void setbTransparent(boolean bTransparent) {
53 | this.bTransparent = bTransparent;
54 | }
55 |
56 | public enum State{
57 | GONE,
58 | LOADING,
59 | LOADING_FALIED,
60 | LOADING_EMPTY
61 | }
62 |
63 |
64 | public UniversalLoadingView(Context context) {
65 | this(context, null);
66 | }
67 |
68 | public UniversalLoadingView(Context context, AttributeSet attrs) {
69 | this(context, attrs, 0);
70 | }
71 |
72 | public UniversalLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
73 | super(context, attrs, defStyleAttr);
74 |
75 | TypedArray t = null;
76 | try {
77 | t = context.obtainStyledAttributes(attrs, R.styleable.MaterialCircleView,
78 | 0, defStyleAttr);
79 | bGradient = t.getBoolean(R.styleable.MaterialCircleView_bGradient, true);
80 | circleColor = t.getColor(R.styleable.MaterialCircleView_circleColor,
81 | getResources().getColor(android.R.color.holo_blue_light));
82 | circleWidth = t.getDimensionPixelSize(R.styleable.MaterialCircleView_circleWidth,
83 | 10);
84 | radius = t.getDimensionPixelSize(R.styleable.MaterialCircleView_radius,
85 | MaterialCircleView.dpToPx(50, getResources()));
86 | } finally {
87 | if (t != null) {
88 | t.recycle();
89 | }
90 | }
91 |
92 | try {
93 | t = context.obtainStyledAttributes(attrs, R.styleable.UniversalLoadingView,
94 | 0, defStyleAttr);
95 | setbTransparent(t.getBoolean(R.styleable.UniversalLoadingView_bg_transparent, false));
96 | alpha = t.getDimensionPixelSize(R.styleable.UniversalLoadingView_bg_alpha,
97 | 255);
98 | } finally {
99 | if (t != null) {
100 | t.recycle();
101 | }
102 | }
103 |
104 | materialCircleView = new MaterialCircleView(context, attrs, defStyleAttr);
105 | // materialCircleView.setbGradient(false);
106 | addView(materialCircleView);
107 |
108 | mTipTextView = new TextView(context);
109 | mTipTextView.setText(LOADING_TIP);
110 | mTipTextView.setTextSize(16f);
111 | mTipTextView.setGravity(Gravity.CENTER);
112 | mTipTextView.setSingleLine(false);
113 | mTipTextView.setMaxLines(2);
114 | mTipTextView.setTextColor(getResources().getColor(android.R.color.darker_gray));
115 | addView(mTipTextView);
116 |
117 | this.setOnClickListener(new OnClickListener() {
118 |
119 | @Override
120 | public void onClick(View v) {
121 | if (mLoadState == State.LOADING_EMPTY || mLoadState == State.LOADING_FALIED) {
122 | if (mReloadListener != null) {
123 | mReloadListener.reload();
124 | }
125 | }
126 | }
127 | });
128 |
129 | mHandler = new Handler();
130 |
131 | if (isbTransparent()) {
132 | setBackgroundColor(getResources().getColor(android.R.color.transparent));
133 | }
134 | }
135 |
136 |
137 | public void postLoadState(State state) {
138 | mLoadState = state;
139 | if(mLoadState == State.GONE) {
140 | this.setVisibility(View.GONE);
141 | }
142 | else if (mLoadState == State.LOADING_FALIED) {
143 | this.setVisibility(View.VISIBLE);
144 | materialCircleView.setVisibility(View.GONE);
145 | mTipTextView.setText(LOAD_FAILED_TIP);
146 |
147 | LayoutParams tipParams = (LayoutParams) mTipTextView.getLayoutParams();
148 | tipParams.top = tipParams.top - 2 * radius;
149 | }else if(mLoadState == State.LOADING_EMPTY) {
150 | this.setVisibility(View.VISIBLE);
151 | materialCircleView.setVisibility(View.VISIBLE);
152 | mTipTextView.setText(LOAD_EMPTY_TIP);
153 |
154 | LayoutParams tipParams = (LayoutParams) mTipTextView.getLayoutParams();
155 | tipParams.top = tipParams.top + 2 * radius;
156 | }
157 | else if(mLoadState == State.LOADING) {
158 | this.setVisibility(View.VISIBLE);
159 | materialCircleView.setVisibility(View.VISIBLE);
160 | mTipTextView.setText(LOADING_TIP);
161 |
162 | LayoutParams tipParams = (LayoutParams) mTipTextView.getLayoutParams();
163 | tipParams.top = tipParams.top + 2 * radius;
164 | }
165 | requestLayout();
166 | invalidate();
167 | }
168 |
169 |
170 | @Override
171 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
172 | // super.onMeasure(widthMeasureSpec, heightMeasureSpec);
173 | measureChildren(widthMeasureSpec, heightMeasureSpec);
174 | LayoutParams params = (LayoutParams) materialCircleView.getLayoutParams();
175 | sWidth = MeasureSpec.getSize(widthMeasureSpec);
176 | sHeight = MeasureSpec.getSize(heightMeasureSpec);
177 | params.left = (sWidth - radius) / 2;
178 | params.top = (sHeight - radius) / 2 - radius;
179 | params.width = radius;
180 | params.height = radius;
181 |
182 | LayoutParams tipParams = (LayoutParams) mTipTextView.getLayoutParams();
183 | int tipWidth = MaterialCircleView.dpToPx(100, getResources());
184 | int tipHeight = MaterialCircleView.dpToPx(50, getResources());
185 | tipParams.left = (sWidth - tipWidth) / 2;
186 | tipParams.top = (sHeight - radius) / 2 ;
187 | tipParams.width = tipWidth;
188 | tipParams.height = tipHeight;
189 |
190 | setMeasuredDimension(sWidth, sHeight);
191 | }
192 |
193 | @Override
194 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
195 | LayoutParams params = (LayoutParams) materialCircleView.getLayoutParams();
196 | materialCircleView.layout(params.left, params.top, params.left + params.width
197 | , params.top + params.height);
198 | LayoutParams tipParams = (LayoutParams) mTipTextView.getLayoutParams();
199 | mTipTextView.layout(tipParams.left, tipParams.top, tipParams.left + tipParams.width,
200 | tipParams.top + tipParams.height);
201 | }
202 |
203 | @Override
204 | protected void onDraw(Canvas canvas) {
205 | super.onDraw(canvas);
206 | }
207 |
208 | public void setTransparent(boolean transparent) {
209 | this.bTransparent = transparent;
210 | requestLayout();
211 | invalidate();
212 | }
213 |
214 | public boolean getIsTransparent () {
215 | return this.bTransparent;
216 | }
217 |
218 | @Override
219 | public boolean onInterceptTouchEvent(MotionEvent ev) {
220 | // return super.onInterceptTouchEvent(ev);
221 | return true;
222 | }
223 |
224 | @Override
225 | public android.view.ViewGroup.LayoutParams generateLayoutParams(
226 | AttributeSet attrs) {
227 | return new UniversalLoadingView.LayoutParams(getContext(), attrs);
228 | }
229 |
230 | @Override
231 | protected android.view.ViewGroup.LayoutParams generateDefaultLayoutParams() {
232 | return new LayoutParams(LayoutParams.WRAP_CONTENT,
233 | LayoutParams.WRAP_CONTENT);
234 | }
235 |
236 | @Override
237 | protected android.view.ViewGroup.LayoutParams generateLayoutParams(
238 | android.view.ViewGroup.LayoutParams p) {
239 | return new LayoutParams(p);
240 | }
241 |
242 | @Override
243 | protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p) {
244 | return p instanceof UniversalLoadingView.LayoutParams;
245 | }
246 |
247 | private static class LayoutParams extends ViewGroup.LayoutParams {
248 |
249 | public int left = 0;
250 | public int top = 0;
251 |
252 | public LayoutParams(Context c, AttributeSet attrs) {
253 | super(c, attrs);
254 | }
255 |
256 | public LayoutParams(int width, int height) {
257 | super(width, height);
258 | }
259 |
260 | public LayoutParams(ViewGroup.LayoutParams source) {
261 | super(source);
262 | }
263 | }
264 |
265 | public void setOnReloadListener(ReloadListner listener) {
266 | this.mReloadListener = listener;
267 | }
268 |
269 | /**
270 | * reload interface
271 | */
272 | public interface ReloadListner {
273 | public void reload();
274 | }
275 | }
276 |
--------------------------------------------------------------------------------