Skip to content

Commit 5dad607

Browse files
committed
NumberProgressBar Born
0 parents  commit 5dad607

36 files changed

+1315
-0
lines changed

Diff for: .gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# built application files
2+
*.apk
3+
*.ap_
4+
5+
# files for the dex VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
.DS_Store
11+
12+
# generated files
13+
bin/
14+
gen/
15+
16+
# Local configuration file (sdk path, etc)
17+
local.properties
18+
19+
# Eclipse project files
20+
.classpath
21+
.project
22+
.settings/
23+
24+
# Proguard folder generated by Eclipse
25+
proguard/
26+
27+
#Android Studio
28+
build/
29+
30+
# Intellij project files
31+
*.iml
32+
*.ipr
33+
*.iws
34+
.idea/
35+
36+
#gradle
37+
.gradle/

Diff for: README.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
##Android NumberProgressBar
2+
3+
-----
4+
5+
The NumberProgressBar is a bar, slim and sexy (every man wants! ).
6+
7+
I decided to do this beacause I'was really tierd of android original progressbar. So, I made some change, added more color style for this.
8+
9+
And also you can contribute more color style, or new idea to me.
10+
11+
----
12+
###Demo
13+
14+
![NumberProgressBar](http://ww3.sinaimg.cn/mw690/610dc034jw1efyrd8n7i7g20cz02mq5f.gif)
15+
16+
###Usage
17+
----
18+
19+
Use it in your own code:
20+
21+
```java
22+
<com.daimajia.numberprogressbar.NumberProgressBar
23+
android:id="@+id/number_progress_bar"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
/>
27+
```
28+
29+
I made some predesign style. You can use them via `style` property.
30+
31+
32+
![Preset color](http://ww1.sinaimg.cn/mw690/610dc034jw1efyslmn5itj20f30k074r.jpg)
33+
34+
Use the preset style just like below:
35+
36+
```java
37+
<com.daimajia.numberprogressbar.NumberProgressBar
38+
android:id="@+id/number_progress_bar"
39+
style="@style/NumberProgressBar_Default"
40+
/>
41+
```
42+
43+
In the above picture, the style is :
44+
45+
`NumberProgressBar_Default`
46+
`NumberProgressBar_Passing_Green`
47+
`NumberProgressBar_Relax_Blue`
48+
`NumberProgressBar_Grace_Yellow`
49+
`NumberProgressBar_Warning_Red`
50+
`NumberProgressBar_Funny_Orange`
51+
`NumberProgressBar_Beauty_Red`
52+
`NumberProgressBar_Twinkle_Night`
53+
54+
You can get more beautiful color from [kular](kuler.adobe.com), and you can also contribute your color style to NumberProgressBar!
55+
56+
###Attributes
57+
58+
There are several attributes you can set:
59+
60+
![](http://ww2.sinaimg.cn/mw690/610dc034jw1efyttukr1zj20eg04bmx9.jpg)
61+
62+
The **reached area** and **unreached area**:
63+
* color
64+
* height
65+
66+
The **text area**:
67+
68+
* color
69+
* text size
70+
* distance between **reached area** and **unreached area**
71+
72+
The **bar**:
73+
74+
* max progress
75+
* current progree
76+
77+
for example, the default style:
78+
79+
```java
80+
<com.daimajia.numberprogressbar.NumberProgressBar
81+
android:layout_width="wrap_content"
82+
android:layout_height="wrap_content"
83+
84+
custom:progress_unreached_color="#CCCCCC"
85+
custom:progress_reached_color="#3498DB"
86+
87+
custom:progress_unreached_bar_height="0.75dp"
88+
custom:progress_reached_bar_height="1.5dp"
89+
90+
custom:progress_text_size="10sp"
91+
custom:progress_text_color="#3498DB"
92+
custom:progress_text_offset="1dp"
93+
94+
custom:max="100"
95+
custom:progress="80"
96+
/>
97+
```
98+
99+
### About me:
100+
101+
A student in China mainland, I like Google, like Android, like open source, like doing something interesting. :)
102+
103+
If you have some new idea or internship opportunity, please [email me](mailto:[email protected]) !
104+
105+
PS: Welcome to visit the site I am maintaining, which is a site to share graceful Android library for every Android developer.
106+
107+
It's name is [Moo Droid](http://moodroid.com) :-D , and also welcome submit your beautiful library to [Moo Droid](http://moodroid.com).

Diff for: build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:0.9.+'
9+
}
10+
}
11+
12+
allprojects {
13+
repositories {
14+
mavenCentral()
15+
}
16+
}

Diff for: demo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: demo/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'android'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion "19.0.3"
6+
7+
defaultConfig {
8+
minSdkVersion 8
9+
targetSdkVersion 19
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
runProguard false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
compile fileTree(dir: 'libs', include: ['*.jar'])
23+
compile 'com.android.support:appcompat-v7:19.+'
24+
compile project(':library')
25+
}

Diff for: demo/proguard-rules.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 ProGuard
5+
# include property in project.properties.
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+
#}

Diff for: demo/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.daimajia.numberprogressbar.example" >
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/ic_launcher"
8+
android:label="NumberProgressBar"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name="com.daimajia.numberprogressbar.example.MainActivity"
12+
android:label="NumberProgressBar" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.daimajia.numberprogressbar.example;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.ActionBarActivity;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
8+
import com.daimajia.numberprogressbar.NumberProgressBar;
9+
10+
import java.util.Timer;
11+
import java.util.TimerTask;
12+
13+
14+
public class MainActivity extends ActionBarActivity {
15+
private int counter = 0;
16+
private Timer timer;
17+
@Override
18+
protected void onCreate(Bundle savedInstanceState) {
19+
super.onCreate(savedInstanceState);
20+
setContentView(R.layout.activity_main);
21+
22+
final NumberProgressBar bnp = (NumberProgressBar)findViewById(R.id.numberbar1);
23+
counter = 0;
24+
setProgress(0);
25+
timer = new Timer();
26+
timer.schedule(new TimerTask() {
27+
@Override
28+
public void run() {
29+
runOnUiThread(new Runnable() {
30+
@Override
31+
public void run() {
32+
bnp.incrementProgressBy(1);
33+
counter ++;
34+
if (counter == 110) {
35+
bnp.setProgress(0);
36+
counter=0;
37+
}
38+
}
39+
});
40+
}
41+
}, 1000, 100);
42+
43+
}
44+
45+
46+
@Override
47+
public boolean onCreateOptionsMenu(Menu menu) {
48+
// Inflate the menu; this adds items to the action bar if it is present.
49+
getMenuInflater().inflate(R.menu.main, menu);
50+
return true;
51+
}
52+
53+
@Override
54+
public boolean onOptionsItemSelected(MenuItem item) {
55+
// Handle action bar item clicks here. The action bar will
56+
// automatically handle clicks on the Home/Up button, so long
57+
// as you specify a parent activity in AndroidManifest.xml.
58+
int id = item.getItemId();
59+
if (id == R.id.action_settings) {
60+
return true;
61+
}
62+
return super.onOptionsItemSelected(item);
63+
}
64+
65+
@Override
66+
protected void onDestroy() {
67+
super.onDestroy();
68+
timer.cancel();
69+
}
70+
}

Diff for: demo/src/main/res/drawable-hdpi/ic_launcher.png

9.18 KB
Loading

Diff for: demo/src/main/res/drawable-mdpi/ic_launcher.png

5.11 KB
Loading

Diff for: demo/src/main/res/drawable-xhdpi/ic_launcher.png

14 KB
Loading

Diff for: demo/src/main/res/drawable-xxhdpi/ic_launcher.png

18.9 KB
Loading

Diff for: demo/src/main/res/layout/activity_main.xml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:custom="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
android:paddingLeft="@dimen/activity_horizontal_margin"
9+
android:paddingRight="@dimen/activity_horizontal_margin"
10+
android:paddingTop="@dimen/activity_vertical_margin"
11+
android:paddingBottom="@dimen/activity_vertical_margin"
12+
android:orientation="vertical"
13+
tools:context="com.daimajia.numberprogressbar.example.MainActivity">
14+
15+
<com.daimajia.numberprogressbar.NumberProgressBar
16+
android:id="@+id/numberbar1"
17+
android:layout_width="wrap_content"
18+
android:padding="20dp"
19+
custom:progress="0"
20+
style="@style/NumberProgressBar_Default"
21+
android:layout_height="wrap_content" />
22+
23+
<com.daimajia.numberprogressbar.NumberProgressBar
24+
android:id="@+id/numberbar2"
25+
android:layout_height="wrap_content"
26+
android:padding="20dp"
27+
custom:progress="20"
28+
android:layout_width="match_parent"
29+
style="@style/NumberProgressBar_Passing_Green"
30+
/>
31+
32+
<com.daimajia.numberprogressbar.NumberProgressBar
33+
android:id="@+id/numberbar3"
34+
android:layout_margin="20dp"
35+
style="@style/NumberProgressBar_Relax_Blue"
36+
custom:progress="30"
37+
android:layout_height="wrap_content" />
38+
39+
<com.daimajia.numberprogressbar.NumberProgressBar
40+
android:id="@+id/numberbar4"
41+
android:layout_width="wrap_content"
42+
android:layout_margin="20dp"
43+
style="@style/NumberProgressBar_Grace_Yellow"
44+
custom:progress="40"
45+
android:layout_height="wrap_content" />
46+
47+
48+
<com.daimajia.numberprogressbar.NumberProgressBar
49+
android:id="@+id/numberbar5"
50+
android:layout_width="wrap_content"
51+
android:layout_margin="20dp"
52+
custom:progress="50"
53+
style="@style/NumberProgressBar_Warning_Red"
54+
android:layout_height="wrap_content" />
55+
56+
57+
<com.daimajia.numberprogressbar.NumberProgressBar
58+
android:id="@+id/numberbar6"
59+
android:layout_width="wrap_content"
60+
android:layout_margin="20dp"
61+
style="@style/NumberProgressBar_Funny_Orange"
62+
custom:progress="60"
63+
android:layout_height="wrap_content" />
64+
65+
<com.daimajia.numberprogressbar.NumberProgressBar
66+
android:id="@+id/numberbar7"
67+
android:layout_width="wrap_content"
68+
android:layout_margin="20dp"
69+
style="@style/NumberProgressBar_Beauty_Red"
70+
custom:progress="70"
71+
android:layout_height="wrap_content" />
72+
73+
<com.daimajia.numberprogressbar.NumberProgressBar
74+
android:id="@+id/numberbar8"
75+
android:layout_width="wrap_content"
76+
android:layout_margin="20dp"
77+
style="@style/NumberProgressBar_Twinkle_Night"
78+
custom:progress="80"
79+
android:layout_height="wrap_content" />
80+
81+
</LinearLayout>

Diff for: demo/src/main/res/menu/main.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
tools:context="com.daimajia.numberprogressbar.example.MainActivity" >
5+
<item android:id="@+id/action_settings"
6+
android:title="@string/action_settings"
7+
android:orderInCategory="100"
8+
app:showAsAction="never" />
9+
</menu>

0 commit comments

Comments
 (0)