Giter Site home page Giter Site logo

circleprogress's Introduction

Android Arsenal

inspired from https://github.com/daimajia/NumberProgressBar

and CleanMaster

CleanMaster

###Demo

CircleProgress

###Demo download link

###3 kinds of progress view are provided, DonutProgress (supports inner drawables and VectorDrawables, CircleProgress, ArcProgress

##Usage

please use jitpack

    allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

###Gradle

dependencies {
    compile 'com.github.lzyzsd:circleprogress:1.2.4'
}

###Notice

please always use same width and height for progress views

DonutProgress

    <com.github.lzyzsd.circleprogress.DonutProgress
        android:layout_marginLeft="50dp"
        android:id="@+id/donut_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        custom:donut_progress="30"/>
    <com.github.lzyzsd.circleprogress.DonutProgress
        android:layout_marginLeft="50dp"
        android:id="@+id/donut_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        custom:donut_finished_color="#0066FF"
        custom:donut_finished_stroke_width="15dp"
        custom:donut_inner_drawable="@drawable/ic_vector_star_black_48dp"
        custom:donut_show_text="false"
        custom:donut_unfinished_color="#f5f5f5"
        custom:donut_unfinished_stroke_width="15dp"/>

DonutProgress

attrs for DonutProgress

    <declare-styleable name="DonutProgress">
        <attr name="donut_progress" format="integer"/>
        <attr name="donut_max" format="integer"/>
        <attr name="donut_unfinished_color" format="color"/>
        <attr name="donut_finished_color" format="color"/>
        <attr name="donut_finished_stroke_width" format="dimension"/>
        <attr name="donut_unfinished_stroke_width" format="dimension"/>
        <attr name="donut_text_size" format="dimension"/>
        <attr name="donut_text_color" format="color"/>
        <attr name="donut_text" format="string"/>
        <attr name="donut_prefix_text" format="string"/>
        <attr name="donut_suffix_text" format="string"/>
        <attr name="donut_background_color" format="color"/>
    </declare-styleable>

CircleProgress

    <com.github.lzyzsd.circleprogress.CircleProgress
        android:id="@+id/circle_progress"
        android:layout_marginLeft="50dp"
        android:layout_width="100dp"
        android:layout_height="100dp"
        custom:circle_progress="20"/>

CircleProgress

attrs for CircleProgress

    <declare-styleable name="CircleProgress">
        <attr name="circle_progress" format="integer"/>
        <attr name="circle_max" format="integer"/>
        <attr name="circle_unfinished_color" format="color"/>
        <attr name="circle_finished_color" format="color"/>
        <attr name="circle_text_size" format="dimension"/>
        <attr name="circle_text_color" format="color"/>
        <attr name="circle_prefix_text" format="string"/>
        <attr name="circle_suffix_text" format="string"/>
    </declare-styleable>

ArcProgress

    <com.github.lzyzsd.circleprogress.ArcProgress
        android:id="@+id/arc_progress"
        android:background="#214193"
        android:layout_marginLeft="50dp"
        android:layout_width="100dp"
        android:layout_height="100dp"
        custom:arc_progress="55"
        custom:arc_bottom_text="MEMORY"/>

ArcProgress

attrs for ArchProgress

    <declare-styleable name="ArcProgress">
        <attr name="arc_progress" format="integer"/>
        <attr name="arc_angle" format="float"/>
        <attr name="arc_stroke_width" format="dimension"/>
        <attr name="arc_max" format="integer"/>
        <attr name="arc_unfinished_color" format="color"/>
        <attr name="arc_finished_color" format="color"/>
        <attr name="arc_text_size" format="dimension"/>
        <attr name="arc_text_color" format="color"/>
        <attr name="arc_suffix_text" format="string"/>
        <attr name="arc_suffix_text_size" format="dimension"/>
        <attr name="arc_suffix_text_padding" format="dimension"/>
        <attr name="arc_bottom_text" format="string"/>
        <attr name="arc_bottom_text_size" format="dimension"/>
    </declare-styleable>

donut_inner_drawable

support add a drawable/vectorDrawable to the center

donut_show_text

show or hide bottom text

###Build

run ./gradlew assembleDebug (Mac/Linux)

or

run gradlew.bat assembleDebug (Windows)

###Changes

version 1.1.0: add bottom text to DonutProgressView

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004

Copyright (C) 2014 Bruce Lee <bruceinpeking#gmail.com>

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.

circleprogress's People

Contributors

ajaysahani avatar ardacebi avatar avafab avatar b0wter avatar chester-king avatar darzul avatar gildor avatar heyitsjs avatar hoseinit avatar jimvang avatar jvr0x avatar kagile avatar liaohuqiu avatar mrwu94 avatar sdarvish avatar t-girniak avatar taoliuh avatar uknownothingsnow avatar vanniktech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circleprogress's Issues

start progress from top

Would it be possible to have attribute wich will let us set starting angle of progress ? Like for values 0 or 360 the progress would start from top of the circle ?

Can you remove unused ic_launcher.png?

Can you remove unused ic_launcher.png?

because of it can cause build error “ic_launcher.png: Original is here.”

maybe you will say i can rename my ic_launcher.png to something else,but other thirdparty library will als forget to remove ic_launcher.png,so, can you remove it?

show timer instead of % in center of circle

I'm trying to show countdown type timer like : 01:30 or 03:50 it's mm:ss but now sure what property to use for it.
I only have option to set prefix and suffix but not the actual text. I have total time for countdown timer in seconds and I can also calculate it to minutes and second, but how do i display it in center ?

If i don't set prefix and suffix it takes 0 by default which I don't want to show.

CircleProgress in Home Widget

Hi,
Can anyone explain how to use this fantastic library in a home widget?
I am having problem in adding this view to the remoteView in my AppWidgetProvider.
Thanks in advance

Drawable support?

Hi,

First of all thanks for the great library! I was digging into the code and I wonder how can I make it show a drawable resource inside the circle (the donut for example) instead of showing the percentage? I tried to modify the class but I have no much experience adding custom attributes and so on.

Thanks!

donut_finished_color not working with negative progress

it seems a problem for me to show negative progress. values show correctly but the finished color and unfinished color get reversed. I wanted to show the same finished color for positive as well as negative color. please help..
thanks.

Small arc does not paint suffix

    <com.github.lzyzsd.circleprogress.ArcProgress
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:id="@+id/arc_progress"
        android:layout_width="40dp"
        android:layout_height="40dp"
        custom:arc_stroke_width="6dp"
        custom:arc_text_size="12dp"
        custom:arc_progress="20"/>

When I debugged it I realized that x and y of drawText are out of box. When I change dimensions to 140dp it looks great.

ArcAngle property is not working

When ever I set the arc angle property in xml file and run the app it fails with
android.view.InflateException: Binary XML file line #128: Error inflating class com.github.lzyzsd.circleprogress.ArcProgress

DonutProgress does not take max into consideration

This line just print actual progress value which works well for default max value (100) but it is incorrect for custom value (e.g. 5). Angle is calculated correctly.

String text = this.text != null ? this.text : prefixText + progress + suffixText;

Views disappears!

I have implemented a view pager which has 3 page in it. My first fragment has arc progress (does not matter which one). When i go to last fragment and turned back to first one which has my arc progress, i cannot see the arc. If i try with it ciricular i cannot see the cirricular then.

I tried to invalidate view to force it re-draw. It didnt fixed.
I think problem may be about restoring state.

Good luck there

Indeterminate Option

Is there any indeterminate option for this progress bar ? Like the progress can continuously spin and if our work is done we can just dismiss it. It would be cool it we can do that.

Bottom text cut on ArcProgress when use Fragment

As per title, I found this issue happens only when using Fragment. I simulate the same thing on Activity, it works perfect.

** There are 3 posts regarding this issue. So I don't know which should I post into.

Float Value Support

This library is excellent !
pls support for float values for progress!
however cast can be used! but i need to show values in float!

thanks in advance!

how can i increase speed of animation /progress bar?

i m getting error in this line

custom:circle_progress="25"
custom:circle_finished_color="#ff0000"
custom:circle_unfinished_color="#00ff00"
custom:circle_text_color="#000000"
custom:circle_suffix_text="$"
custom:circle_text_size="16sp"

Multiple annotations found at this line:
- error: No resource identifier found for attribute 'circle_text_size' in package 'com.example.batterylevel'
- error: No resource identifier found for attribute 'circle_suffix_text' in package
'com.example.batterylevel'
- error: No resource identifier found for attribute 'circle_finished_color' in package
'com.example.batterylevel'
- error: No resource identifier found for attribute 'circle_progress' in package 'com.example.batterylevel'
- error: No resource identifier found for attribute 'circle_unfinished_color' in package
'com.example.batterylevel'
- error: No resource identifier found for attribute 'circle_text_color' in package 'com.example.batterylevel'

Set color programatically ?

Hello,

First of all thanks for this very nice and easy use library :-)

I'd like to know if it's possible to change the finished_color programatically. I'm having trouble doing it :

Using donutProgress.setFinishedStrokeColor(R.color.orange); or whatever color won't do anything, instead it puts a blue/purple color as you can see below :

issue_donut_progress

Am I using setFinishedStrokeColor the right way ?
Thanks in advance, Max

Background is deleted

Hi,
I'm using https://github.com/gabrielemariotti/cardslib.
I have CardListView and in the cards i have CircleProgress.
When the user first enter the CardListView , it shows the CircleProgress with the background colors.
But When i move between activities and than returning to the CardListView i can only see the percentage without any background color...
Thanks,
Amit

ArcProgress in Listview

Hi
I want to use ArcProgress in ListView. I'm declare ArcProgress in listview item layout and when I run my app I saw ArcProgress without arc and bottom text visible only for half. No matter what size of ArcProgress always the same.
How can i solve this ?
device-2014-11-28-064908

ArchView rendering issue in Nexus 5X

In Nexus 5 it is working completely fine of rendering archview but in nexus 5x it is not working properly.
screenshot_20160316-193046 nexus 5

screenshot_20160316-162524
nexus 5X

When i try to see Debug GPU overdraw with Show areas for Deuteranomaly. It clearly shows arch is generating but GPU is drawing oval on it.

screenshot_20160316-162444

Can you look in to this issue and revert me back. Thanks.

Arc Angle Problem

When I add the arc_angle property in my ArcProgress:

<com.github.lzyzsd.circleprogress.ArcProgress
        android:id="@+id/arc"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:arc_angle="360"/>

I get a warning: Dimension "360" in attribute "arc_angle" is missing unit!

And if I ignore the warning and run I get an exception:

android.view.InflateException: Binary XML file line #20: Error inflating class com.github.lzyzsd.circleprogress.ArcProgress
    at android.view.LayoutInflater.createView(LayoutInflater.java:640)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
    ...
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
    at android.view.LayoutInflater.createView(LayoutInflater.java:614)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
    ...
 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x4
    at android.content.res.TypedArray.getDimension(TypedArray.java:508)
    at com.github.lzyzsd.circleprogress.ArcProgress.initByAttributes(ArcProgress.java:101)
    at com.github.lzyzsd.circleprogress.ArcProgress.<init>(ArcProgress.java:90)
    at com.github.lzyzsd.circleprogress.ArcProgress.<init>(ArcProgress.java:74)
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:415)

Observation: I'm using this view in a fragment

Please release v1.2.0

Hey.

I've seen you have changed a lot of things since the v1.1.0 including a commit where unnecessary resources got removed.
I would love to update my com.android.tools.build:gradle:1.1.3 to com.android.tools.build:gradle:1.2.3` but this is not possible because your v1.1.0 of your library still includes the ic_launcher drawable, which was already removed in a commit.

Thanks in advance.

(CircleProgress) Last view "saved" ? Getting the same % for all views

Hi,

I'm saving my data in a database and when I load the fragment for a first time, it does a great job :
First load
And then, at the second and furthers loads : it displays only 83%.
Second load

When I debug here it displays me the good %. But in the View, i see only 83% as you saw before.
Debug

Any ideas if it is a bug ?

DonutProgress Inner Bottom Text dissappearing

I am using Donut Progress in a recycler view under a view pager. The inner bottom text mysteriously appears and disappears of its own accord, after the view is recreated. Even though the same code is used to bind the view to the recycler view. Some Donut progress have the inner text, some don't.
Top of the list Top of the list
After scrolling downwards After scrolling downwards

Animation on ArcProgress

Please help me, how can i Animate ArcProgress?? i'll appreciate if you can explain with detailed discription

DonutProgress draw arc wrongly.

screenshot_2015-02-27-13-57-24
As the image above ,

     if (finishedStrokeWidth > unfinishedStrokeWidth) {
            finishedOuterRect.set(finishedStrokeWidth / 2,
                finishedStrokeWidth / 2,
                getWidth() - finishedStrokeWidth / 2,
                getHeight() - finishedStrokeWidth / 2);
            float delta = (finishedStrokeWidth - unfinishedStrokeWidth) / 2f;
            unfinishedOuterRect.set(unfinishedStrokeWidth / 2,
                unfinishedStrokeWidth / 2,
                getWidth() - unfinishedStrokeWidth / 2 - delta,
                getHeight() - unfinishedStrokeWidth / 2 - delta);
        } else {
            float delta = (unfinishedStrokeWidth - finishedStrokeWidth) / 2f;
            finishedOuterRect.set(finishedStrokeWidth / 2,
                finishedStrokeWidth / 2,
                getWidth() - finishedStrokeWidth / 2 - delta,
                getHeight() - finishedStrokeWidth / 2 - delta);
            unfinishedOuterRect.set(unfinishedStrokeWidth / 2,
                unfinishedStrokeWidth / 2,
                getWidth() - unfinishedStrokeWidth / 2,
                getHeight() - unfinishedStrokeWidth / 2);
        }

I modified so it would like this:
    float delta = Math.max(finishedStrokeWidth, unfinishedStrokeWidth);
    finishedOuterRect.set(delta,
            delta,
            getWidth() - delta,
            getHeight() - delta);
    unfinishedOuterRect.set(delta,
            delta,
            getWidth() - delta,
            getHeight() - delta);

screenshot_2015-02-27-14-06-14

the problem resolved, and I commited a PR.

DonutProgress not updated

Hi,

I tried your lib, but I'm facing some troubles.
When i put donutProgress.setProgress(92) (programmatically), doesn't work.
In XML no troubles, but i can't do it in code.
Then, I tried to getProgress with donutProgress.getProgress() & it returns my previous setProgress (92).

Any idea?

BR,
Bastien.

[EDIT]
My bad, just selected header layout instead of inflated layout.

ArcProgress can not be used without an AttributeSet

Hi,

I am showing a few simple arcs in different colors and in different rows via a recylced view adapter. However changing the arc color does not cause initPainters to be called again, meaning the setting is never applied. Basically all properties used by initPainters can not be changed via the public setX API.

I'm currently fixing this by inheritance

public class ArcProgress extends com.github.lzyzsd.circleprogress.ArcProgress {
    public ArcProgress(Context context) { super(context); }
    public ArcProgress(Context context, AttributeSet attrs) { super(context, attrs); }
    public ArcProgress(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
    protected void onDraw(Canvas canvas) {
        initPainters();
        super.onDraw(canvas);
    }
}

which is ugly and slow but works.

It would be nice if the initPainters logic would be changed to make programatic changes possible.

This might be related to issue #1 - the symptoms are at least the same but I can't identify if it's the same root cause.

(PS: I am getting the arc color via an API, which means I am unable to determine it ahead of time. D'oh)

How to hide text inside donutprogress?

Hi, I would like to set donutprogress with no text inside it. Only circle. I try using

custom:donut_prefix_text=""
custom:donut_suffix_text=""
custom:donut_text=""

But the number progress inside it still showing.

Add LICENSE file

Can you add a license file to indicate the license this code falls under?

Please update the latest version on maven central

Hi,

I can see the version 1.2.0 on your release branch details.
But it seems the new version is not pushed to the maven central repository, due to that I can't use the latest version. Please update it.

Text ArcProgress Cut

the text that has the ArcProgress is cut

use the same layout MyActivity a fragment and got this result in Moto G 4.4.4

screenshot_2015-01-06-10-04-41

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.