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) { enum class DrawableFormat(val extension: String) {
UNKNOWN(""), UNKNOWN(""),
//XML("xml"),
SVG("svg"), SVG("svg"),
JPG("jpg"), JPG("jpg"),
PNG("png"); PNG("png");
@ -69,6 +67,7 @@ data class DrawableData(val value: ByteArray, val format: DrawableFormat) {
val bitmap = BitmapFactory.decodeByteArray(value, 0, value.size) val bitmap = BitmapFactory.decodeByteArray(value, 0, value.size)
BitmapDrawable(resources, bitmap) BitmapDrawable(resources, bitmap)
} }
DrawableFormat.SVG -> { DrawableFormat.SVG -> {
val svg = SVG.getFromInputStream(ByteArrayInputStream(value)) val svg = SVG.getFromInputStream(ByteArrayInputStream(value))
val picture = svg.renderToPicture() 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()) 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 else -> null
} }
} catch (e: Exception) { } catch (e: Exception) {

View file

@ -165,7 +165,7 @@ class CwfInfosActivity : TranslatedDaggerAppCompatActivity() {
val cwfView = viewList[position] val cwfView = viewList[position]
val key = cwfView.first.key val key = cwfView.first.key
val value = cwfView.first.comment 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) { with(holder.cwfInfosActivityViewItemBinding) {
viewKey.text = "\"$key\":" viewKey.text = "\"$key\":"
viewComment.text = rh.gs(value) viewComment.text = rh.gs(value)