question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading images with custom progress will report an error:Don't know how to round that drawable

See original GitHub issue

Load images with custom progress

GenericDraweeHierarchy build = GenericDraweeHierarchyBuilder.newInstance(mContext.getResources()) .setFadeDuration(1000) .setProgressBarImage(new ImageLoadingDrawable()) .build(); iv.setHierarchy(build); iv.setImageURI(item.getFile_path());

This is my custom progress loading

public class ImageLoadingDrawable extends Drawable {
    private Paint mRingBackgroundPaint;
    private int mRingBackgroundColor;
    private Paint mRingPaint;
    private int mRingColor;
    private float mRadius;
    private float mRingRadius;
    private float mStrokeWidth;
    private int mXCenter;
    private int mYCenter;
    private int mTotalProgress = 10000;
    private int mProgress;
    public ImageLoadingDrawable(){
        initAttrs();
    }

    private void initAttrs() {
        mRadius = 64;
        mStrokeWidth = 16;
        mRingBackgroundColor = 0xFFadadad;
        mRingColor = 0xFF0EB6D2;
        mRingRadius = mRadius + mStrokeWidth / 2;
        initVariable();
    }

    private void initVariable() {
        mRingBackgroundPaint = new Paint();
        mRingBackgroundPaint.setAntiAlias(true);
        mRingBackgroundPaint.setColor(mRingBackgroundColor);
        mRingBackgroundPaint.setStyle(Paint.Style.STROKE);
        mRingBackgroundPaint.setStrokeWidth(mStrokeWidth);

        mRingPaint = new Paint();
        mRingPaint.setAntiAlias(true);
        mRingPaint.setColor(mRingColor);
        mRingPaint.setStyle(Paint.Style.STROKE);
        mRingPaint.setStrokeWidth(mStrokeWidth);
    }

    @Override
    public void draw(Canvas canvas) {
        drawBar(canvas,mTotalProgress,mRingBackgroundPaint);
        drawBar(canvas,mProgress,mRingPaint);
    }

    private void drawBar(Canvas canvas, int level, Paint paint) {
        if (level > 0 ) {
            Rect bound= getBounds();
            mXCenter = bound.centerX();
            mYCenter = bound.centerY();
            RectF oval = new RectF();
            oval.left = (mXCenter - mRingRadius);
            oval.top = (mYCenter - mRingRadius);
            oval.right = mRingRadius * 2 + (mXCenter - mRingRadius);
            oval.bottom = mRingRadius * 2 + (mYCenter - mRingRadius);
            canvas.drawArc(oval, -90, ((float) level / mTotalProgress) * 360, false, paint); //
        }
    }

    @Override
    protected boolean onLevelChange(int level) {
        mProgress = level;
        if(level > 0 && level < 10000) {
            invalidateSelf();
            return true;
        }else {
            return false;
        }
    }

    @Override
    public void setAlpha(int alpha) {
        mRingPaint.setAlpha(alpha);
    }

    @Override
    public void setColorFilter(ColorFilter cf) {
        mRingPaint.setColorFilter(cf);
    }

    @Override
    public int getOpacity() {
        return DrawableUtils.getOpacityFromColor(this.mRingPaint.getColor());
    }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
oprisnikcommented, Jul 15, 2019

It seems like you’re setting rounding parameters. Fresco doesn’t know how your custom drawable should be rounded. However, it’s just a warning, not an error, see https://github.com/facebook/fresco/blob/6d3a538525d2eab10bd59400ee1fcaf9569bdf79/drawee/src/main/java/com/facebook/drawee/generic/WrappingUtils.java#L321

Rounding of other drawables is not supported right now, as to the documentation here: https://frescolib.org/docs/rounded-corners-and-circles.html

0reactions
KimiChiucommented, Oct 12, 2021

Is there a way to disable this warning? It’s slowing down everything and make it jittery on scrolling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Progress bar while loading image using Glide - Stack Overflow
I am trying to do that using .placeholder(R.Drawable.spinner) no animation is coming up? It would be great if somebody could help me out?...
Read more >
Loading Images progress bar - Google Cloud Community
There is a "Loading Images" progress bar under the hamburger menu...almost at the bottom. My question is...I want to know what images it...
Read more >
Circular Determinate ProgressBar with Background and Text
In this tutorial, we will learn how to create a circular progress bar in Android Studio that displays the current progress value and...
Read more >
Custom Progress Bar in Android - DigitalOcean
In this tutorial, we'll create a custom progress bar by implementing a spinning logo icon in our application. Most of the time, we...
Read more >
WPF SplashScreen - Overview - Telerik UI for WPF
Customizable image content: The control allows you to easily set the splash screen image. ... You can easily change this and indicate some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found