Skip to content

Commit

Permalink
NumberProgressBar Born
Browse files Browse the repository at this point in the history
  • Loading branch information
daimajia committed May 1, 2014
0 parents commit 5dad607
Show file tree
Hide file tree
Showing 36 changed files with 1,315 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class
.DS_Store

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project
.settings/

# Proguard folder generated by Eclipse
proguard/

#Android Studio
build/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

#gradle
.gradle/
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
##Android NumberProgressBar

-----

The NumberProgressBar is a bar, slim and sexy (every man wants! ).

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.

And also you can contribute more color style, or new idea to me.

----
###Demo

![NumberProgressBar](http://ww3.sinaimg.cn/mw690/610dc034jw1efyrd8n7i7g20cz02mq5f.gif)

###Usage
----

Use it in your own code:

```java
<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/number_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
```

I made some predesign style. You can use them via `style` property.


![Preset color](http://ww1.sinaimg.cn/mw690/610dc034jw1efyslmn5itj20f30k074r.jpg)

Use the preset style just like below:

```java
<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/number_progress_bar"
style="@style/NumberProgressBar_Default"
/>
```

In the above picture, the style is :

`NumberProgressBar_Default`
`NumberProgressBar_Passing_Green`
`NumberProgressBar_Relax_Blue`
`NumberProgressBar_Grace_Yellow`
`NumberProgressBar_Warning_Red`
`NumberProgressBar_Funny_Orange`
`NumberProgressBar_Beauty_Red`
`NumberProgressBar_Twinkle_Night`

You can get more beautiful color from [kular](kuler.adobe.com), and you can also contribute your color style to NumberProgressBar!

###Attributes

There are several attributes you can set:

![](http://ww2.sinaimg.cn/mw690/610dc034jw1efyttukr1zj20eg04bmx9.jpg)

The **reached area** and **unreached area**:
* color
* height

The **text area**:

* color
* text size
* distance between **reached area** and **unreached area**

The **bar**:

* max progress
* current progree

for example, the default style:

```java
<com.daimajia.numberprogressbar.NumberProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"

custom:progress_unreached_color="#CCCCCC"
custom:progress_reached_color="#3498DB"

custom:progress_unreached_bar_height="0.75dp"
custom:progress_reached_bar_height="1.5dp"

custom:progress_text_size="10sp"
custom:progress_text_color="#3498DB"
custom:progress_text_offset="1dp"

custom:max="100"
custom:progress="80"
/>
```

### About me:

A student in China mainland, I like Google, like Android, like open source, like doing something interesting. :)

If you have some new idea or internship opportunity, please [email me](mailto:[email protected]) !

PS: Welcome to visit the site I am maintaining, which is a site to share graceful Android library for every Android developer.

It's name is [Moo Droid](http://moodroid.com) :-D , and also welcome submit your beautiful library to [Moo Droid](http://moodroid.com).
16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}

allprojects {
repositories {
mavenCentral()
}
}
1 change: 1 addition & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.3"

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile project(':library')
}
17 changes: 17 additions & 0 deletions demo/proguard-rules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
21 changes: 21 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.daimajia.numberprogressbar.example" >

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="NumberProgressBar"
android:theme="@style/AppTheme" >
<activity
android:name="com.daimajia.numberprogressbar.example.MainActivity"
android:label="NumberProgressBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.daimajia.numberprogressbar.example;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

import com.daimajia.numberprogressbar.NumberProgressBar;

import java.util.Timer;
import java.util.TimerTask;


public class MainActivity extends ActionBarActivity {
private int counter = 0;
private Timer timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final NumberProgressBar bnp = (NumberProgressBar)findViewById(R.id.numberbar1);
counter = 0;
setProgress(0);
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
bnp.incrementProgressBy(1);
counter ++;
if (counter == 110) {
bnp.setProgress(0);
counter=0;
}
}
});
}
}, 1000, 100);

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
protected void onDestroy() {
super.onDestroy();
timer.cancel();
}
}
Binary file added demo/src/main/res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/src/main/res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/src/main/res/drawable-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.daimajia.numberprogressbar.example.MainActivity">

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar1"
android:layout_width="wrap_content"
android:padding="20dp"
custom:progress="0"
style="@style/NumberProgressBar_Default"
android:layout_height="wrap_content" />

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar2"
android:layout_height="wrap_content"
android:padding="20dp"
custom:progress="20"
android:layout_width="match_parent"
style="@style/NumberProgressBar_Passing_Green"
/>

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar3"
android:layout_margin="20dp"
style="@style/NumberProgressBar_Relax_Blue"
custom:progress="30"
android:layout_height="wrap_content" />

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar4"
android:layout_width="wrap_content"
android:layout_margin="20dp"
style="@style/NumberProgressBar_Grace_Yellow"
custom:progress="40"
android:layout_height="wrap_content" />


<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar5"
android:layout_width="wrap_content"
android:layout_margin="20dp"
custom:progress="50"
style="@style/NumberProgressBar_Warning_Red"
android:layout_height="wrap_content" />


<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar6"
android:layout_width="wrap_content"
android:layout_margin="20dp"
style="@style/NumberProgressBar_Funny_Orange"
custom:progress="60"
android:layout_height="wrap_content" />

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar7"
android:layout_width="wrap_content"
android:layout_margin="20dp"
style="@style/NumberProgressBar_Beauty_Red"
custom:progress="70"
android:layout_height="wrap_content" />

<com.daimajia.numberprogressbar.NumberProgressBar
android:id="@+id/numberbar8"
android:layout_width="wrap_content"
android:layout_margin="20dp"
style="@style/NumberProgressBar_Twinkle_Night"
custom:progress="80"
android:layout_height="wrap_content" />

</LinearLayout>
9 changes: 9 additions & 0 deletions demo/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.daimajia.numberprogressbar.example.MainActivity" >
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
Loading

0 comments on commit 5dad607

Please sign in to comment.