Wear cwf clean code

This commit is contained in:
Philoul 2023-08-26 23:16:58 +02:00
parent 11d0bce4ef
commit 8cda7d8c0b
2 changed files with 4 additions and 13 deletions

View file

@ -45,8 +45,6 @@ enum class CwfDrawableFileMap(val key: String, @DrawableRes val icon: Int?, val
enum class DrawableFormat(val extension: String) {
UNKNOWN(""),
//XML("xml"),
SVG("svg"),
JPG("jpg"),
PNG("png");
@ -69,6 +67,7 @@ data class DrawableData(val value: ByteArray, val format: DrawableFormat) {
val bitmap = BitmapFactory.decodeByteArray(value, 0, value.size)
BitmapDrawable(resources, bitmap)
}
DrawableFormat.SVG -> {
val svg = SVG.getFromInputStream(ByteArrayInputStream(value))
val picture = svg.renderToPicture()
@ -76,15 +75,7 @@ data class DrawableData(val value: ByteArray, val format: DrawableFormat) {
setBounds(0, 0, svg.documentWidth.toInt(), svg.documentHeight.toInt())
}
}
/*
DrawableFormat.XML -> {
// Always return a null Drawable, even if xml file is a valid xml vector file
val xmlInputStream = ByteArrayInputStream(value)
val xmlPullParser = Xml.newPullParser()
xmlPullParser.setInput(xmlInputStream, null)
Drawable.createFromXml(resources, xmlPullParser)
}
*/
else -> null
}
} catch (e: Exception) {

View file

@ -165,7 +165,7 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() {
val cwfView = viewList[position]
val key = cwfView.first.key
val value = cwfView.first.comment
val visible = cwfView.second // will be used if all keys included into RecyclerView
//val visible = cwfView.second // will be used if all keys included into RecyclerView
with(holder.cwfInfosActivityViewItemBinding) {
viewKey.text = "\"$key\":"
viewComment.text = rh.gs(value)