Fabio
07/02/2021, 2:48 AMpainterResource
throws exception for some drawables and we can't write try/catch in @Composable
functions, how can I work around not crashing my app?
painterResource
calls loadVectorResource
who calls loadVectorResource
private fun loadVectorResource(theme: Resources.Theme, res: Resources, id: Int): ImageVector {
@Suppress("ResourceType") val parser = res.getXml(id)
if (parser.seekToStartTag().name != "vector") {
throw IllegalArgumentException(errorMessage)
}
return loadVectorResourceInner(theme, res, parser)
}
It crashes for an image such as this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="<http://schemas.android.com/apk/res/android>">
<item>
<shape android:shape="oval">
<solid android:color="@color/colorBardeenBrand" />
</shape>
</item>
</layer-list>
Ian Lake
07/02/2021, 3:04 AM<vector>
resource, so the crash makes senseFabio
07/02/2021, 4:49 AMFabio
07/02/2021, 4:50 AMImage
but wondering if there's an alternativeFabio
07/02/2021, 4:53 AM@Composable
?
as a side note, if there's any docs/blogs/vlogs about the try/catch decision I'd be interested in reading itcb
07/02/2021, 6:56 AMDrawablePainter
from Accompanist https://google.github.io/accompanist/api/imageloading-core/imageloading-core/com.google.accompanist.imageloading/remember-drawable-painter.htmlFabio
07/02/2021, 7:11 AMcb
07/02/2021, 7:24 AMFabio
07/05/2021, 12:27 AM-coil
and -pager
this week 🙂 , image placeholders are just the cherry on topcb
07/05/2021, 12:47 PM