├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── leo
│ │ └── simpleloader
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── leo
│ │ └── simpleloader
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── preview
├── simplearcdialog_1.gif
└── simplearcdialog_2.gif
├── settings.gradle
└── simplearcloader
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── simplearcloader.iml
└── src
├── androidTest
└── java
│ └── com
│ └── leo
│ └── simplearcloader
│ └── ApplicationTest.java
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── leo
│ └── simplearcloader
│ ├── ArcConfiguration.java
│ ├── SimpleArcDialog.java
│ └── SimpleArcLoader.java
└── res
├── layout
└── loader_layout.xml
└── values
├── attrs.xml
├── dimens.xml
└── strings.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | Android
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 | 1.7
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://android-arsenal.com/details/1/3066)
2 | # SimpleArcLoader
3 | - bored of seeing the same old Android Loader ? SimpleArcLoader is one thing you should try.
4 |
5 | # Preview
6 |
7 |
8 |
9 | # Setup
10 | ## Gradle
11 | ```groovy
12 | dependencies {
13 | compile 'com.leo.simplearcloader:simplearcloader:1.0.+'
14 | }
15 | ```
16 |
17 | ## Example 1
18 | To show dialog
19 | ```java
20 | SimpleArcDialog mDialog = new SimpleArcDialog(this);
21 | mDialog.setConfiguration(new ArcConfiguration(this));
22 | mDialog.show();
23 | ```
24 | ## Example 2
25 | Making use of just the Loader
26 | ```xml
27 |
36 |
37 | ```
38 | ## Example 3
39 | Customizing Dialog/SimpleArcLoader View using ArcConfiguration
40 | ```java
41 | ArcConfiguration configuration = new ArcConfiguration(context);
42 | configuration.setLoaderStyle(SimpleArcLoader.STYLE.COMPLETE_ARC);
43 | configuration.setText("Please wait..");
44 |
45 | // Using this configuration with Dialog
46 | mDialog.setConfiguration(configuration);
47 |
48 | // Using this configuration with ArcLoader
49 | mSimpleArcLoader.refreshArcLoaderDrawable(configuration);
50 | ```
51 |
52 | You can customize Arc/Dialog with ArcConfiguration methods -
53 | - setLoaderStyle(SimpleArcLoader.STYLE mLoaderStyle)
54 | - setArcMargin(int mArcMargin)
55 | - setArcWidthInPixel(int mStrokeWidth)
56 | - setColors(int[] colors)
57 | - setTypeFace(Typeface typeFace)
58 | - setText(String mText)
59 | - setTextColor(int mTextColor)
60 | - setTextSize(int size)
61 | - setAnimationSpeedWithIndex(int mAnimationIndex)
62 | Values to be passed SimpleArcLoader.SPEED_SLOW, SimpleArcLoader.SPEED_MEDIUM, SimpleArcLoader.SPEED_FAST
63 |
64 | Please refer the examples for some of the customization.
65 |
66 | # Developed By
67 | - prathamesh.s1989@gmail.com
68 |
69 | # License
70 |
71 | Copyright 2016 Prathamesh Sawant
72 |
73 | Licensed under the Apache License, Version 2.0 (the "License");
74 | you may not use this file except in compliance with the License.
75 | You may obtain a copy of the License at
76 |
77 | http://www.apache.org/licenses/LICENSE-2.0
78 |
79 | Unless required by applicable law or agreed to in writing, software
80 | distributed under the License is distributed on an "AS IS" BASIS,
81 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82 | See the License for the specific language governing permissions and
83 | limitations under the License.
84 |
85 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
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 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.leo.simpleloader"
9 | minSdkVersion 9
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0.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:22.1.1'
25 | compile project(':simplearcloader')
26 | }
27 |
--------------------------------------------------------------------------------
/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 /Users/prathamesh/Library/Android/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/androidTest/java/com/leo/simpleloader/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.leo.simpleloader;
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/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/leo/simpleloader/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.leo.simpleloader;
2 |
3 | import android.content.DialogInterface;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.LinearLayout;
8 |
9 | import com.leo.simplearcloader.ArcConfiguration;
10 | import com.leo.simplearcloader.SimpleArcDialog;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 |
19 | final LinearLayout mRootView = (LinearLayout)findViewById(R.id.rootlayout);
20 |
21 | final SimpleArcDialog mDialog = new SimpleArcDialog(MainActivity.this);
22 | mDialog.setConfiguration(new ArcConfiguration(MainActivity.this));
23 | mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
24 | @Override
25 | public void onDismiss(DialogInterface dialogInterface) {
26 | mRootView.setVisibility(View.VISIBLE);
27 | }
28 | });
29 |
30 | findViewById(R.id.loaderButtonRandom).setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View view) {
33 | mRootView.setVisibility(View.INVISIBLE);
34 | mDialog.show();
35 | }
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
15 |
16 |
24 |
25 |
37 |
38 |
39 |
40 |
41 |
46 |
47 |
53 |
54 |
58 |
59 |
60 |
65 |
66 |
70 |
71 |
72 |
73 |
74 |
75 |
79 |
80 |
83 |
84 |
85 |
92 |
93 |
99 |
100 |
106 |
107 |
116 |
117 |
118 |
125 |
126 |
127 |
128 |
134 |
135 |
144 |
145 |
146 |
153 |
154 |
155 |
156 |
157 |
158 |
162 |
163 |
167 |
168 |
172 |
173 |
179 |
180 |
188 |
189 |
190 |
197 |
198 |
199 |
200 |
206 |
207 |
216 |
217 |
218 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
242 |
243 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SimpleLoader
3 |
4 |
5 | - #FFFFFF
6 | - #FFFFFF
7 |
8 |
9 |
10 | - #c2c200
11 |
12 |
13 |
14 | - #531ac5
15 |
16 |
17 |
18 | - #531ac5
19 | - #4367ff
20 | - #ff662e
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 |
13 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jan 16 21:06:59 GMT+05:30 2016
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.4-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/preview/simplearcdialog_1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/preview/simplearcdialog_1.gif
--------------------------------------------------------------------------------
/preview/simplearcdialog_2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prathameshsawant9/SimpleArcLoader/bb0cc96c8147cf471a2a31d2407492ffb9c2b9af/preview/simplearcdialog_2.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':simplearcloader'
2 |
--------------------------------------------------------------------------------
/simplearcloader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/simplearcloader/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'simpleloader'
6 |
7 | // CAN BE A PACKAGE NAME USED AS '':''"1.0.0
8 | publishedGroupId = 'com.leo.simplearcloader'
9 |
10 | // CAN BE NAME OF THE APP
11 | libraryName = 'SimpleLoader'
12 |
13 | // ARTIFACT NAME SHOULD MATCH THE LIBRARY NAME
14 | artifact = 'simplearcloader'
15 |
16 | // ITS MORE LIKE
17 | // publishedGroupId:artifact:libraryVersion
18 |
19 | libraryDescription = 'Bored of seeing the same old Android Loader ? SimpleArcLoader is one thing you should try.'
20 |
21 | siteUrl = 'https://github.com/generic-leo/SimpleArcLoader'
22 | gitUrl = 'https://github.com/generic-leo/SimpleArcLoader.git'
23 |
24 | libraryVersion = '1.0.3'
25 |
26 | developerId = 'generic-leo'
27 | developerName = 'Prathamesh Sawant'
28 | developerEmail = 'leo.studio89@gmail.com'
29 |
30 | licenseName = 'The Apache Software License, Version 2.0'
31 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
32 | allLicenses = ["Apache-2.0"]
33 | }
34 |
35 | android {
36 | compileSdkVersion 22
37 | buildToolsVersion "23.0.2"
38 |
39 | defaultConfig {
40 | minSdkVersion 9
41 | targetSdkVersion 22
42 | versionCode 3
43 | versionName "1.0.3"
44 | }
45 | buildTypes {
46 | release {
47 | minifyEnabled false
48 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 | compile fileTree(dir: 'libs', include: ['*.jar'])
55 | compile 'com.android.support:appcompat-v7:22.1.1'
56 | }
57 |
58 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
59 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
--------------------------------------------------------------------------------
/simplearcloader/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 /Users/prathamesh/Library/Android/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 |
--------------------------------------------------------------------------------
/simplearcloader/simplearcloader.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
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 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/simplearcloader/src/androidTest/java/com/leo/simplearcloader/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.leo.simplearcloader;
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 | }
--------------------------------------------------------------------------------
/simplearcloader/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/java/com/leo/simplearcloader/ArcConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.leo.simplearcloader;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.Typeface;
6 |
7 | /**
8 | * Created by prathamesh on 16/01/16.
9 | */
10 | public class ArcConfiguration
11 | {
12 | // =============================================================================================
13 | // CONSTANTS
14 | // =============================================================================================
15 |
16 |
17 | // =============================================================================================
18 | // FIELDS
19 | // =============================================================================================
20 |
21 | private SimpleArcLoader.STYLE mLoaderStyle;
22 |
23 | private Typeface mTypeFace = null;
24 | private String mText = "Loading..";
25 | private int mTextSize = 0;
26 | private int mTextColor = Color.WHITE;
27 |
28 | private int mArcMargin;
29 | private int mAnimationSpeed;
30 | private int mStrokeWidth;
31 | private boolean mArcCircle;
32 | private int mColors[] = {Color.parseColor("#F90101"), // RED
33 | Color.parseColor("#0266C8"), // BLUE
34 | Color.parseColor("#F2B50F"), // YELLOW
35 | Color.parseColor("#00933B")};// GREEN
36 |
37 |
38 | // =============================================================================================
39 | // CONSTRUCTOR
40 | // =============================================================================================
41 |
42 | private ArcConfiguration() {}
43 |
44 | public ArcConfiguration(Context context) {
45 |
46 | // Default Values
47 | mLoaderStyle = SimpleArcLoader.STYLE.SIMPLE_ARC;
48 | mArcMargin = SimpleArcLoader.MARGIN_MEDIUM;
49 | mAnimationSpeed = SimpleArcLoader.SPEED_MEDIUM;
50 | mStrokeWidth = (int) context.getResources().getDimension(R.dimen.stroke_width);
51 | }
52 |
53 | public ArcConfiguration(Context context, SimpleArcLoader.STYLE mArcStyle) {
54 | this(context);
55 |
56 | mLoaderStyle = mArcStyle;
57 | }
58 |
59 | // =============================================================================================
60 | // METHODS
61 | // =============================================================================================
62 |
63 | public SimpleArcLoader.STYLE getLoaderStyle() {
64 | return mLoaderStyle;
65 | }
66 |
67 | public void setLoaderStyle(SimpleArcLoader.STYLE mLoaderStyle) {
68 | this.mLoaderStyle = mLoaderStyle;
69 | }
70 |
71 | public int getArcMargin() {
72 | return mArcMargin;
73 | }
74 |
75 | public void setArcMargin(int mArcMargin) {
76 | this.mArcMargin = mArcMargin;
77 | }
78 |
79 | public int getAnimationSpeed() {
80 | return mAnimationSpeed;
81 | }
82 |
83 | public void setAnimationSpeed(int mAnimationSpeed) {
84 | this.mAnimationSpeed = mAnimationSpeed;
85 | }
86 |
87 | public void setAnimationSpeedWithIndex(int mAnimationIndex) {
88 |
89 | switch (mAnimationIndex) {
90 | case 0:
91 | this.mAnimationSpeed = SimpleArcLoader.SPEED_SLOW;
92 | break;
93 |
94 | case 1:
95 | this.mAnimationSpeed = SimpleArcLoader.SPEED_MEDIUM;
96 | break;
97 |
98 | case 2:
99 | this.mAnimationSpeed = SimpleArcLoader.SPEED_FAST;
100 | break;
101 | }
102 | }
103 |
104 | public int getArcWidth() {
105 | return mStrokeWidth;
106 | }
107 |
108 | public void setArcWidthInPixel(int mStrokeWidth) {
109 | this.mStrokeWidth = mStrokeWidth;
110 | }
111 |
112 | public void setColors(int[] colors) {
113 | if (colors.length > 0)
114 | mColors = colors;
115 | }
116 |
117 | public int[] getColors() {
118 | return mColors;
119 | }
120 |
121 | public void setTypeFace(Typeface typeFace) {
122 | mTypeFace = typeFace;
123 | }
124 |
125 | public Typeface getTypeFace()
126 | {
127 | return mTypeFace;
128 | }
129 |
130 | public void setText(String mText)
131 | {
132 | this.mText = mText;
133 | }
134 |
135 | public String getText()
136 | {
137 | return mText;
138 | }
139 |
140 | public void setTextSize(int size)
141 | {
142 | mTextSize = size;
143 | }
144 |
145 | public int getTextSize()
146 | {
147 | return mTextSize;
148 | }
149 |
150 | public int getTextColor() {
151 | return mTextColor;
152 | }
153 |
154 | public void setTextColor(int mTextColor)
155 | {
156 | this.mTextColor = mTextColor;
157 | }
158 |
159 | public boolean drawCircle()
160 | {
161 | return this.mArcCircle;
162 | }
163 |
164 | public void drawCircle(boolean drawCircle)
165 | {
166 | this.mArcCircle = drawCircle;
167 | }
168 | }
169 |
170 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/java/com/leo/simplearcloader/SimpleArcDialog.java:
--------------------------------------------------------------------------------
1 | package com.leo.simplearcloader;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.graphics.Color;
6 | import android.graphics.Typeface;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.graphics.drawable.GradientDrawable;
9 | import android.os.Bundle;
10 | import android.view.View;
11 | import android.view.Window;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 |
15 | /**
16 | * Created by prathamesh on 16/01/16.
17 | */
18 | public class SimpleArcDialog extends Dialog {
19 | // =============================================================================================
20 | // CONSTANTS
21 | // =============================================================================================
22 |
23 |
24 | // =============================================================================================
25 | // FIELDS
26 | // =============================================================================================
27 |
28 | private SimpleArcLoader mLoaderView;
29 | private ArcConfiguration mConfiguration;
30 | private LinearLayout mLayout;
31 | private TextView mLoadingText;
32 | private boolean showWindow = true;
33 |
34 | // =============================================================================================
35 | // CONSTRUCTOR
36 | // =============================================================================================
37 |
38 | public SimpleArcDialog(Context context) {
39 | super(context);
40 | }
41 |
42 | public SimpleArcDialog(Context context, ArcConfiguration configuration) {
43 | super(context);
44 | mConfiguration = configuration;
45 | }
46 |
47 | public SimpleArcDialog(Context context, int themeResId,ArcConfiguration configuration) {
48 | super(context, themeResId);
49 | mConfiguration = configuration;
50 | }
51 |
52 | public SimpleArcDialog(Context context, boolean cancelable, OnCancelListener cancelListener,ArcConfiguration configuration) {
53 | super(context, cancelable, cancelListener);
54 | mConfiguration = configuration;
55 | }
56 |
57 | // =============================================================================================
58 | // METHODS
59 | // =============================================================================================
60 |
61 | @Override
62 | protected void onCreate(Bundle savedInstanceState) {
63 | super.onCreate(savedInstanceState);
64 |
65 | requestWindowFeature(Window.FEATURE_NO_TITLE);
66 | getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
67 | setContentView(R.layout.loader_layout);
68 |
69 | mLoaderView = (SimpleArcLoader) findViewById(R.id.loader);
70 | mLoadingText = (TextView) findViewById(R.id.loadertext);
71 | mLayout = (LinearLayout) findViewById(R.id.window);
72 | mLoadingText.setTextColor(Color.BLACK);
73 |
74 | if (mConfiguration != null) {
75 | mLoaderView.refreshArcLoaderDrawable(mConfiguration);
76 | updateLoadingText(mConfiguration);
77 | }
78 |
79 | if(showWindow)
80 | {
81 | GradientDrawable gd = new GradientDrawable();
82 | gd.setColor(Color.WHITE);
83 | gd.setCornerRadius(10);
84 | gd.setStroke(2, Color.WHITE);
85 | mLayout.setBackgroundDrawable(gd);
86 |
87 | if(mConfiguration != null && mConfiguration.getTextColor() == Color.WHITE)
88 | mLoadingText.setTextColor(Color.BLACK);
89 | }
90 | }
91 |
92 | private void updateLoadingText(ArcConfiguration configuration) {
93 | String text = configuration.getText();
94 |
95 | if (text.trim().length() == 0) {
96 | mLoadingText.setVisibility(View.GONE);
97 | } else {
98 | mLoadingText.setText(configuration.getText());
99 | }
100 |
101 |
102 | Typeface typeface = configuration.getTypeFace();
103 | if (typeface != null)
104 | mLoadingText.setTypeface(typeface);
105 |
106 | int textSize = configuration.getTextSize();
107 |
108 | if (textSize > 0)
109 | mLoadingText.setTextSize(textSize);
110 |
111 |
112 | mLoadingText.setTextColor(mConfiguration.getTextColor());
113 | }
114 |
115 | public LinearLayout getLayout()
116 | {
117 | return mLayout;
118 | }
119 |
120 | public TextView getLoadingTextView()
121 | {
122 | return mLoadingText;
123 | }
124 |
125 | public void setConfiguration(ArcConfiguration configuration) {
126 | mConfiguration = configuration;
127 | }
128 |
129 | public void showWindow(boolean state)
130 | {
131 | showWindow = true;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/java/com/leo/simplearcloader/SimpleArcLoader.java:
--------------------------------------------------------------------------------
1 | package com.leo.simplearcloader;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.ColorFilter;
8 | import android.graphics.Paint;
9 | import android.graphics.PixelFormat;
10 | import android.graphics.RectF;
11 | import android.graphics.drawable.Animatable;
12 | import android.graphics.drawable.Drawable;
13 | import android.os.SystemClock;
14 | import android.util.AttributeSet;
15 | import android.view.View;
16 |
17 | import java.lang.ref.WeakReference;
18 |
19 | /**
20 | * Created by prathamesh on 16/01/16.
21 | */
22 | public class SimpleArcLoader extends View implements Animatable
23 | {
24 | // =============================================================================================
25 | // CONSTANTS
26 | // =============================================================================================
27 |
28 | private static long FRAME_DURATION = 1000 / 60;
29 |
30 | public static int MARGIN_NONE = 0;
31 | public static int MARGIN_MEDIUM = 5;
32 | public static int MARGIN_LARGE = 10;
33 |
34 | public static int SPEED_SLOW = 1;
35 | public static int SPEED_MEDIUM = 5;
36 | public static int SPEED_FAST = 10;
37 |
38 | public static int STROKE_WIDTH_DEFAULT = 10;
39 |
40 | public enum STYLE {SIMPLE_ARC, COMPLETE_ARC}
41 |
42 | // =============================================================================================
43 | // FIELDS
44 | // =============================================================================================
45 |
46 | ArcDrawable mArcDrawable;
47 |
48 | // =============================================================================================
49 | // CONSTRUCTORS
50 | // =============================================================================================
51 |
52 | public SimpleArcLoader(Context context) {
53 | super(context);
54 | }
55 |
56 | public SimpleArcLoader(Context context, AttributeSet attrs) {
57 | super(context, attrs);
58 |
59 | init(attrs);
60 | }
61 |
62 | public SimpleArcLoader(Context context, AttributeSet attrs, int defStyleAttr) {
63 | super(context, attrs, defStyleAttr);
64 |
65 | init(attrs);
66 | }
67 |
68 | public SimpleArcLoader(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
69 | super(context, attrs, defStyleAttr, defStyleRes);
70 |
71 | init(attrs);
72 | }
73 |
74 | // =============================================================================================
75 | // METHODS
76 | // =============================================================================================
77 |
78 | private void init(AttributeSet attributeSet) {
79 | ArcConfiguration configuration = readFromAttributes(attributeSet);
80 |
81 | // Load Drawable for this View
82 | mArcDrawable = new ArcDrawable(configuration,this);
83 | setBackgroundDrawable(mArcDrawable);
84 |
85 | // Start the Animation
86 | start();
87 | }
88 |
89 | private ArcConfiguration readFromAttributes(AttributeSet attributeSet) {
90 | ArcConfiguration configuration = new ArcConfiguration(getContext());
91 |
92 | TypedArray array = getContext().obtainStyledAttributes(attributeSet, R.styleable.SimpleArcLoader);
93 |
94 | for (int i = 0; i < array.length(); i++) {
95 | int type = array.getIndex(i);
96 |
97 | if (type == R.styleable.SimpleArcLoader_arc_style) {
98 | String value = array.getString(R.styleable.SimpleArcLoader_arc_style);
99 |
100 | configuration.setLoaderStyle(STYLE.values()[Integer.parseInt(value)]);
101 | }
102 |
103 | if (type == R.styleable.SimpleArcLoader_arc_colors) {
104 | int colors_resourse_id = array.getResourceId(R.styleable.SimpleArcLoader_arc_colors, 0);
105 |
106 | if (colors_resourse_id != 0)
107 | configuration.setColors(getContext().getResources().getIntArray(colors_resourse_id));
108 | }
109 |
110 | if (type == R.styleable.SimpleArcLoader_arc_speed) {
111 | String value = array.getString(R.styleable.SimpleArcLoader_arc_speed);
112 |
113 | if(value != null)
114 | configuration.setAnimationSpeedWithIndex(Integer.parseInt(value));
115 | }
116 |
117 | if (type == R.styleable.SimpleArcLoader_arc_margin) {
118 | Float value = array.getDimension(R.styleable.SimpleArcLoader_arc_margin, MARGIN_MEDIUM);
119 |
120 | configuration.setArcMargin(value.intValue());
121 | }
122 |
123 | if(type == R.styleable.SimpleArcLoader_arc_thickness)
124 | {
125 | Float value = array.getDimension(R.styleable.SimpleArcLoader_arc_thickness,getContext().getResources().getDimension(R.dimen.stroke_width));
126 | configuration.setArcWidthInPixel(value.intValue());
127 | }
128 | }
129 |
130 | array.recycle();
131 |
132 | return configuration;
133 | }
134 |
135 | @Override
136 | public void start() {
137 | if (mArcDrawable != null)
138 | mArcDrawable.start();
139 | }
140 |
141 | @Override
142 | public void stop() {
143 | if (mArcDrawable != null)
144 | mArcDrawable.stop();
145 | }
146 |
147 | @Override
148 | public boolean isRunning() {
149 |
150 | if (mArcDrawable != null)
151 | return mArcDrawable.isRunning();
152 |
153 | return false;
154 | }
155 |
156 | public void refreshArcLoaderDrawable(ArcConfiguration configuration) {
157 | if(isRunning())
158 | stop();
159 |
160 | // Load Drawable for this View
161 | mArcDrawable = new ArcDrawable(configuration,this);
162 | setBackgroundDrawable(mArcDrawable);
163 |
164 | // Start the Animation
165 | start();
166 | }
167 |
168 | // =============================================================================================
169 | // CLASS
170 | // =============================================================================================
171 |
172 | private static class ArcDrawable extends Drawable implements Animatable
173 | {
174 | final Runnable updater = new Runnable() {
175 | @Override
176 | public void run() {
177 | mArcAnglePosition += mAnimationSpeed;
178 |
179 | if(mArcAnglePosition > 360)
180 | mArcAnglePosition = 0;
181 |
182 | scheduleSelf(updater,FRAME_DURATION + SystemClock.uptimeMillis());
183 | invalidateSelf();
184 | }
185 | };
186 |
187 | ArcConfiguration mConfiguration;
188 | Paint mPaint;
189 | int mStrokeWidth,mArcMargin,mArcAnglePosition,mAnimationSpeed;
190 | int mArcColors[];
191 | boolean isRunning;
192 | boolean mDrawCirle;
193 | WeakReference mViewReference;
194 |
195 | public ArcDrawable(ArcConfiguration configuration,View viewReference) {
196 | mConfiguration = configuration;
197 | mViewReference = new WeakReference(viewReference);
198 |
199 | initComponents();
200 | }
201 |
202 | private void initComponents()
203 | {
204 | mStrokeWidth = mConfiguration.getArcWidth();
205 | mArcMargin = mConfiguration.getArcMargin();
206 | mArcColors = mConfiguration.getColors();
207 | mAnimationSpeed = mConfiguration.getAnimationSpeed();
208 | mDrawCirle = mConfiguration.drawCircle();
209 |
210 | mPaint = new Paint();
211 | mPaint.setAntiAlias(true);
212 | mPaint.setStrokeWidth(mStrokeWidth);
213 | mPaint.setStyle(Paint.Style.STROKE);
214 |
215 | // Customize as per Style
216 | if(mConfiguration.getLoaderStyle() == STYLE.SIMPLE_ARC)
217 | {
218 | if(mArcColors.length > 1)
219 | mArcColors = new int[]{mArcColors[0],mArcColors[0]};
220 | }
221 | }
222 |
223 | @Override
224 | public void start() {
225 | if(!isRunning())
226 | {
227 | // Set the flag
228 | isRunning = true;
229 |
230 | scheduleSelf(updater,FRAME_DURATION + SystemClock.uptimeMillis());
231 | invalidateSelf();
232 | }
233 | }
234 |
235 | @Override
236 | public void stop() {
237 | if(isRunning())
238 | {
239 | // Set the flag
240 | isRunning = false;
241 |
242 | unscheduleSelf(updater);
243 | invalidateSelf();
244 | }
245 | }
246 |
247 | @Override
248 | public boolean isRunning() {
249 | return isRunning;
250 | }
251 |
252 | @Override
253 | public void draw(Canvas canvas) {
254 | View currentView = mViewReference.get();
255 |
256 | if(currentView == null)
257 | return;
258 |
259 | int w = currentView.getWidth();
260 | int h = currentView.getHeight();
261 |
262 | int arc1_bound_start = mArcMargin + mStrokeWidth*2;
263 | int arc_padding = 0;
264 |
265 | if(mDrawCirle)
266 | {
267 | mPaint.setStyle(Paint.Style.FILL);
268 | mPaint.setColor(Color.WHITE);
269 | canvas.drawCircle(w / 2, h / 2, w / 2, mPaint);
270 |
271 | // Reset the configuration
272 | mPaint.setStyle(Paint.Style.STROKE);
273 |
274 | // Add some padding
275 | arc_padding +=3;
276 | }
277 |
278 | RectF arc1_bound = new RectF(arc1_bound_start + arc_padding,arc1_bound_start + arc_padding, ((w-(mStrokeWidth*2)) - mArcMargin ) - arc_padding,((h-(mStrokeWidth*2)) - mArcMargin) - arc_padding);
279 | RectF arc2_bound = new RectF(mStrokeWidth + arc_padding ,mStrokeWidth + arc_padding,(w-mStrokeWidth) - arc_padding ,( h-mStrokeWidth ) - arc_padding);
280 | int colors_length = mArcColors.length;
281 |
282 | for(int i = 0 ; i < (colors_length > 4 ? 4 : colors_length ) ; i++ )
283 | {
284 | int startangle = (90*i);
285 |
286 | mPaint.setColor(mArcColors[i]);
287 |
288 | canvas.drawArc(arc1_bound, startangle + mArcAnglePosition, 90 , false, mPaint);
289 | canvas.drawArc(arc2_bound, startangle - mArcAnglePosition, 90 , false, mPaint);
290 | }
291 | }
292 |
293 | @Override
294 | public void setAlpha(int i) {}
295 |
296 | @Override
297 | public void setColorFilter(ColorFilter colorFilter) {}
298 |
299 | @Override
300 | public int getOpacity() {
301 | return PixelFormat.UNKNOWN;
302 | }
303 | }
304 |
305 | }
306 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/res/layout/loader_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
19 |
20 |
26 |
27 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | // SIMPLE_ARC,COMPLETE_ARC,SIMPLE_ARC_DIALOG,COMPLETE_ARC_DIALOG
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3dp
4 |
--------------------------------------------------------------------------------
/simplearcloader/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SimpleArcLoader
3 |
4 |
--------------------------------------------------------------------------------