uknownothingsnow / CircleProgress

CircleProgress, DonutProgress, ArcProgress
3.81k stars 920 forks source link

ArcProgress can not be used without an AttributeSet #2

Closed rtreffer closed 9 years ago

rtreffer commented 9 years ago

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)

uknownothingsnow commented 9 years ago

fixed in latest code, renew painters and invalid in setters, like your solution, thanks for feedback.