alexzhirkevich / custom-qr-generator

Android library for creating QR codes with logo, custom shapes, colors, background image. Powered by ZXing
MIT License
173 stars 18 forks source link

Logo from url #20

Closed lJanusl closed 1 year ago

lJanusl commented 1 year ago

Can you add the option to load a logo from the url and not just from resources? please

Thank you for your work, is very nice this library.

alexzhirkevich commented 1 year ago

Hi, @lJanusl.

Thanks.

You can load logo drawable by yourself, for example using Glide and create custom DrawableSource. Is it public interface.


val logo : Drawable = loadDrawableFromWeb()

val options = createQrVectorOptions {
    logo {
        drawable = DrawableSource { logo } // it is 'fun interface'
    }
}

But don't load logo inside DrawableSource.get method. It is suspend now, but runs blocking in QrCodeDrawable and it will no longer be suspend in next version

// Don't do this (it will freeze your app)

DrawableSource { loadDrawableFromWeb() } 
lJanusl commented 1 year ago

thanks a lot!