├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── gavinguo.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── scopes
│ └── scope_settings.xml
└── vcs.xml
├── CustomAccelerateBall.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── test
│ │ └── gavinguo
│ │ └── customaccelerateball
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── test
│ │ └── gavinguo
│ │ └── customaccelerateball
│ │ ├── AccelerateBallView.java
│ │ └── CustomAccelerateBallActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ ├── background.jpg
│ ├── ic_launcher.png
│ ├── lever.png
│ └── taskmanager_water_top.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable
│ └── task_killer_full_clip.xml
│ ├── layout
│ ├── custom_accelerate_ball_activity.xml
│ └── custome_accelerate.xml
│ ├── menu
│ └── custom_accelerate_ball.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── accelerateball_attrs.xml
│ ├── accelerateball_defaults.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pic.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | CustomAccelerateBall
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/gavinguo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Android
15 |
16 |
17 | Android Lint
18 |
19 |
20 | Java language level migration aids
21 |
22 |
23 |
24 |
25 | Abstraction issues
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Android API 18 Platform
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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CustomAccelerateBall.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CustomAccelerateBall
2 | accelerate ball,加速球效果,也就是圆形的ProgressBar的效果。
3 |
4 | ##效果图
5 | 录制效果不是很好
6 | >
7 | 
8 |
9 | ##功能
10 | * 可以设置目标位置,让它自己加速到特定位置。
11 | * 可以设置不适用加速的动画效果,直接设置到特定位置。
12 | * 可以设置是否显示Percent。
13 | * 可以设置刷新速度,RefreshSpeed。
14 | * 可以设置加速动画涨幅,Speed。
15 | * 可以设置加速过程监听,每次变化监听回调,加速结束回调,AccelerateBallUpdateListener。
16 |
17 | ##layout
18 | ```xml
19 |
29 | ```
30 |
31 | ##展示类型
32 | ```java
33 | public enum GalleryType{
34 | NoneAnimationAndPercent,//没有动画和百分比文字
35 | NoneAnimationHavePercent,//没有动画但是有文本
36 | AnimationOnly,//只有动画
37 | AnimationAndPercent,//具有动画和百分比,default
38 | }
39 | ```
40 |
41 | ##动画涨幅
42 | ```java
43 | public enum Speed{
44 | slow,//低速
45 | medium,//中速,default
46 | fast,//高速
47 | superFast,//超高速
48 | random,//随机速度
49 | }
50 | ```
51 |
52 | ##刷新速度
53 | ```java
54 | public enum RefreshSpeed{
55 | slow,//低速
56 | medium,//中速,default
57 | fast,//高速
58 | superFast,//超高速
59 | }
60 | ```
61 |
62 | ##过程监听
63 | ```java
64 | public interface AccelerateBallUpdateListener{
65 | /**
66 | * 每次变化
67 | * @param currentPercent 当前百分比
68 | */
69 | void updateLeveUp(int currentPercent);
70 |
71 | /**
72 | * 上涨结束调用
73 | * @param endPercent 结束时候的百分比
74 | */
75 | void endLeveUp(int endPercent);
76 | }
77 | ```
78 | ##设置参数以及启动
79 | ```java
80 | ball = (AccelerateBallView) findViewById(R.id.ball);
81 | ball.setSpeedType(AccelerateBallView.Speed.superFast);
82 | ball.setRefreshSpeedType(AccelerateBallView.RefreshSpeed.superFast);
83 | ball.setGalleryType(AccelerateBallView.GalleryType.AnimationAndPercent);
84 | ball.setAccelerateBallUpdateListener(new AccelerateBallView.AccelerateBallUpdateListener() {
85 | @Override
86 | public void updateLeveUp(int currentPercent) {
87 | //do nothing
88 | }
89 |
90 | @Override
91 | public void endLeveUp(int endPercent) {
92 | //do nothing
93 | }
94 | });
95 | start.setOnClickListener(this);
96 | ball.setTotalLevel(totalLevel);
97 | ```
98 | Total可以不停的去设置,加速球最终会停止在最后设置的位置。
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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.test.gavinguo.customaccelerateball"
9 | minSdkVersion 15
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | runProguard false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | }
25 |
--------------------------------------------------------------------------------
/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 D:\developerTool\as\install\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/test/gavinguo/customaccelerateball/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.test.gavinguo.customaccelerateball;
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 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/test/gavinguo/customaccelerateball/AccelerateBallView.java:
--------------------------------------------------------------------------------
1 | package com.test.gavinguo.customaccelerateball;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.ClipDrawable;
7 | import android.os.Handler;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.widget.ImageView;
13 | import android.widget.RelativeLayout;
14 | import android.widget.TextView;
15 |
16 | /**
17 | * Created by gavinguo on 5/11/2015.
18 | */
19 | public class AccelerateBallView extends RelativeLayout {
20 |
21 | /** 上下文 **/
22 | private Context mContext;
23 | /** 加载的View **/
24 | private View contentView;
25 | /** 加速球的透明遮罩层 **/
26 | private ImageView maskView;
27 | /** 加速球的level **/
28 | private ImageView levelView;
29 | /** 显示百分比的文字控件 **/
30 | private TextView percentView;
31 | /** 目标水平 **/
32 | private int totalLevel;
33 | /** 当前位置 **/
34 | private int currentLevel;
35 |
36 | /** 最大水平不能超过10000 **/
37 | private final int MAX_LEVEL = 10000;
38 | private final int slowLength = 5;
39 | private final int mediumLength = 10;
40 | private final int fastLength = 15;
41 | private final int superFastLength = 50;
42 | private final int slowRefresh = 15;
43 | private final int mediumRefresh = 10;
44 | private final int fastRefresh = 5;
45 | private final int superFastRefresh = 1;
46 |
47 | /** 变化速度 **/
48 | private int levelUpSpeed = slowLength;
49 | /** 刷新速度 **/
50 | private int refreshSpeed = fastRefresh;
51 |
52 | /** 控制上涨动画 **/
53 | private Handler mHandler = null;
54 | private Runnable levelUpRunnable = null;
55 |
56 | /** 标记当前是否正在运行中,处理多次设置totalLevel问题 **/
57 | private boolean isRuning = false;
58 |
59 | /** 变化监听接口 **/
60 | private AccelerateBallUpdateListener accelerateBallUpdateListener;
61 |
62 | /** 标记展示类型,默认是具有动画的百分比文字 **/
63 | private GalleryType galleryType = GalleryType.AnimationAndPercent;
64 | /**
65 | * 提供展示类型
66 | */
67 | public enum GalleryType{
68 | NoneAnimationAndPercent,//没有动画和百分比文字
69 | NoneAnimationHavePercent,//没有动画但是有文本
70 | AnimationOnly,//只有动画
71 | AnimationAndPercent,//具有动画和百分比,默认
72 | }
73 |
74 | /** 标记上涨速度类型 **/
75 | private Speed speedType = Speed.medium;
76 | /**
77 | * 提供上涨速度
78 | */
79 | public enum Speed{
80 | slow,//低速
81 | medium,//中速
82 | fast,//高速
83 | superFast,//超高速
84 | random,//随机速度
85 | }
86 |
87 | /** 标记刷新类型 **/
88 | private RefreshSpeed refreshSpeedType = RefreshSpeed.medium;
89 | /**
90 | * 刷新速度
91 | */
92 | public enum RefreshSpeed{
93 | slow,//低速
94 | medium,//中速
95 | fast,//高速
96 | superFast,//超高速
97 | }
98 |
99 | /**
100 | * 加速球变化监听
101 | */
102 | public interface AccelerateBallUpdateListener{
103 | /**
104 | * 每次变化
105 | * @param currentPercent 当前百分比
106 | */
107 | void updateLeveUp(int currentPercent);
108 |
109 | /**
110 | * 上涨结束调用
111 | * @param endPercent 结束时候的百分比
112 | */
113 | void endLeveUp(int endPercent);
114 | }
115 |
116 | /**
117 | * 构造方法
118 | * @param context
119 | * @param attrs
120 | */
121 | public AccelerateBallView(Context context, AttributeSet attrs) {
122 | super(context, attrs);
123 | this.mContext = context;
124 | LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
125 | contentView = inflater.inflate(R.layout.custome_accelerate, this);
126 |
127 | Resources resources = context.getResources();
128 | TypedArray arr = context.obtainStyledAttributes(attrs,R.styleable.accelerateBallView);
129 | int galleryTypeArr = arr.getInt(R.styleable.accelerateBallView_galleryType,resources.getInteger(R.integer.accelerateball_gallerytype_default));
130 | galleryType = GalleryType.values()[galleryTypeArr];
131 | int speedArr = arr.getInt(R.styleable.accelerateBallView_speed,resources.getInteger(R.integer.accelerateball_speed_default));
132 | setSpeedType(Speed.values()[speedArr]);
133 | int refreshSpeedArr = arr.getInt(R.styleable.accelerateBallView_refreshSpeed,resources.getInteger(R.integer.accelerateball_refreshspeed_default));
134 | setRefreshSpeedType(RefreshSpeed.values()[refreshSpeedArr]);
135 | currentLevel = arr.getInt(R.styleable.accelerateBallView_initLevel,resources.getInteger(R.integer.accelerateball_gallerytype_initlevel));
136 | if(currentLevel > MAX_LEVEL){
137 | throw new IllegalArgumentException("initLevel can't more than " + MAX_LEVEL);
138 | }
139 | arr.recycle();
140 |
141 | initView();
142 | }
143 |
144 | /**
145 | * 初始化控件
146 | */
147 | private void initView(){
148 | maskView = (ImageView) contentView.findViewById(R.id.image_mask);
149 | levelView = (ImageView) contentView.findViewById(R.id.image_level);
150 | percentView = (TextView) contentView.findViewById(R.id.percent);
151 | //是否需要显示
152 | if(galleryType == GalleryType.AnimationAndPercent){
153 | int percentValue = (int)(currentLevel * 100 / MAX_LEVEL);
154 | percentView.setVisibility(View.VISIBLE);
155 | percentView.setText(percentValue+"%");
156 | }else{
157 | percentView.setVisibility(View.GONE);
158 | }
159 | ClipDrawable clip = (ClipDrawable) levelView.getDrawable();
160 | clip.setLevel(currentLevel);
161 | percentView.setText("0%");
162 | }
163 |
164 | /**
165 | * 设置目标位置
166 | * @param totalLevelParam
167 | */
168 | public void setTotalLevel(int totalLevelParam) {
169 | if(totalLevelParam > MAX_LEVEL){
170 | throw new IllegalArgumentException("totalLevel can't more than " + MAX_LEVEL);
171 | }
172 | this.totalLevel = totalLevelParam;
173 | if(galleryType == GalleryType.AnimationAndPercent || galleryType == GalleryType.AnimationOnly){
174 | if(mHandler == null && levelUpRunnable == null){
175 | mHandler = new Handler();
176 | levelUpRunnable = new Runnable(){
177 |
178 | @Override
179 | public void run() {
180 |
181 | //是否需要随机生成上涨速度
182 | if(speedType == Speed.random){
183 | levelUpSpeed = (int)(Math.random()*fastLength);
184 | }
185 |
186 | currentLevel = currentLevel+levelUpSpeed;
187 |
188 | if(currentLevel > totalLevel){
189 | currentLevel = totalLevel;
190 | }
191 |
192 | ClipDrawable clip = (ClipDrawable) levelView.getDrawable();
193 | clip.setLevel(currentLevel);
194 |
195 | int percentValue = (int)(currentLevel * 100 / MAX_LEVEL);
196 |
197 | //调用接口返回变化监听
198 | if(accelerateBallUpdateListener != null){
199 | accelerateBallUpdateListener.updateLeveUp(percentValue);
200 | }
201 |
202 | //是否需要显示
203 | if(galleryType == GalleryType.AnimationAndPercent){
204 | percentView.setVisibility(View.VISIBLE);
205 | percentView.setText(percentValue+"%");
206 | }else{
207 | percentView.setVisibility(View.GONE);
208 | }
209 |
210 | //到达目标位置则暂停
211 | if(currentLevel != totalLevel){
212 | //刷新频率为15ms每次
213 | mHandler.postDelayed(levelUpRunnable,refreshSpeed);
214 | }else{
215 | isRuning = false;
216 | pauseLevelUp();
217 | //调用接口返回结束监听
218 | if(accelerateBallUpdateListener != null){
219 | accelerateBallUpdateListener.endLeveUp(percentValue);
220 | }
221 | }
222 |
223 | }
224 | };
225 | }
226 | //不是false的话,说明正在运行,那么就不需要重新启动,修改了totalLevel就可以了。
227 | if(!isRuning){
228 | isRuning = true;
229 | startLevelUp();
230 | }
231 | }else{
232 | ClipDrawable clip = (ClipDrawable) levelView.getDrawable();
233 | clip.setLevel(totalLevel);
234 | if(galleryType == GalleryType.NoneAnimationHavePercent){
235 | int percentValue = (int)(totalLevel * 100 / MAX_LEVEL);
236 | percentView.setText(percentValue+"%");
237 | }
238 | }
239 | }
240 |
241 | public GalleryType getGalleryType() {
242 | return galleryType;
243 | }
244 |
245 | /**
246 | *暂停上涨
247 | */
248 | public void pauseLevelUp(){
249 | mHandler.removeCallbacks(levelUpRunnable);
250 | }
251 |
252 | /**
253 | * 开始上涨
254 | */
255 | public void startLevelUp(){
256 | mHandler.post(levelUpRunnable);
257 | }
258 |
259 | /**
260 | * 结束上涨,最好在不适用该控件的地方调用这个方法,对于暂时,请调用@pauseLevelUp(),否则,会出现异常
261 | */
262 | public void stopLevelUp(){
263 | mHandler.removeCallbacks(levelUpRunnable);
264 | mHandler = null;
265 | levelUpRunnable = null;
266 | }
267 |
268 | /**
269 | * 设置展示类型
270 | * @param galleryType
271 | */
272 | public void setGalleryType(GalleryType galleryType) {
273 | this.galleryType = galleryType;
274 | }
275 |
276 | public Speed getSpeedType() {
277 | return speedType;
278 | }
279 |
280 | /**
281 | * 设置展示速度
282 | */
283 | public void setSpeedType(Speed speedType) {
284 | this.speedType = speedType;
285 | switch (speedType){
286 | case slow:
287 | levelUpSpeed = slowLength;
288 | break;
289 | case medium:
290 | levelUpSpeed = mediumLength;
291 | break;
292 | case fast:
293 | levelUpSpeed = fastLength;
294 | break;
295 | case superFast:
296 | levelUpSpeed = superFastLength;
297 | break;
298 | case random:
299 | //该类型在每次上涨的时候具体生成
300 | break;
301 | }
302 | }
303 |
304 | public RefreshSpeed getRefreshSpeedType() {
305 | return refreshSpeedType;
306 | }
307 |
308 | /**
309 | * 设置刷新速度
310 | * @param refreshSpeedType
311 | */
312 | public void setRefreshSpeedType(RefreshSpeed refreshSpeedType) {
313 | this.refreshSpeedType = refreshSpeedType;
314 | switch (refreshSpeedType){
315 | case slow:
316 | refreshSpeed = slowRefresh;
317 | break;
318 | case medium:
319 | refreshSpeed = mediumRefresh;
320 | break;
321 | case fast:
322 | refreshSpeed = fastRefresh;
323 | break;
324 | case superFast:
325 | refreshSpeed = superFastRefresh;
326 | break;
327 | }
328 | }
329 |
330 | public int getTotalLevel() {
331 | return totalLevel;
332 | }
333 |
334 | public AccelerateBallUpdateListener getAccelerateBallUpdateListener() {
335 | return accelerateBallUpdateListener;
336 | }
337 |
338 | public void setAccelerateBallUpdateListener(AccelerateBallUpdateListener accelerateBallUpdateListener) {
339 | this.accelerateBallUpdateListener = accelerateBallUpdateListener;
340 | }
341 |
342 | }
343 |
--------------------------------------------------------------------------------
/app/src/main/java/com/test/gavinguo/customaccelerateball/CustomAccelerateBallActivity.java:
--------------------------------------------------------------------------------
1 | package com.test.gavinguo.customaccelerateball;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 |
10 | /**
11 | * Created by gavinguo on 5/6/2015.
12 | */
13 | public class CustomAccelerateBallActivity extends Activity implements View.OnClickListener{
14 |
15 | private EditText percent;
16 | private Button start;
17 | private AccelerateBallView ball;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.custom_accelerate_ball_activity);
23 | percent = (EditText) findViewById(R.id.percent_content);
24 | start = (Button) findViewById(R.id.start);
25 | ball = (AccelerateBallView) findViewById(R.id.ball);
26 | // ball.setSpeedType(AccelerateBallView.Speed.superFast);
27 | // ball.setRefreshSpeedType(AccelerateBallView.RefreshSpeed.superFast);
28 | // ball.setGalleryType(AccelerateBallView.GalleryType.AnimationAndPercent);
29 | ball.setAccelerateBallUpdateListener(new AccelerateBallView.AccelerateBallUpdateListener() {
30 | @Override
31 | public void updateLeveUp(int currentPercent) {
32 | //do nothing
33 | }
34 |
35 | @Override
36 | public void endLeveUp(int endPercent) {
37 | //do nothing
38 | }
39 | });
40 | start.setOnClickListener(this);
41 | }
42 |
43 | @Override
44 | public void onClick(View v) {
45 | int totalLevel = Integer.parseInt(percent.getText().toString());
46 | ball.setTotalLevel(totalLevel);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-xhdpi/background.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/lever.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-xhdpi/lever.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/taskmanager_water_top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-xhdpi/taskmanager_water_top.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/task_killer_full_clip.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_accelerate_ball_activity.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
18 |
19 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custome_accelerate.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
14 |
15 |
21 |
22 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/custom_accelerate_ball.xml:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/accelerateball_attrs.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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/accelerateball_defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3
4 | 3
5 | 3
6 | 0
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 |
3 |
4 | CustomAccelerateBall
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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:0.12.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/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=http\://services.gradle.org/distributions/gradle-1.12-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 |
--------------------------------------------------------------------------------
/pic.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guoGavin/CustomAccelerateBall/e47cba714c74833f42e656f272cb781e36d2ecdc/pic.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------