Wear cwf clean code
This commit is contained in:
parent
11d0bce4ef
commit
8cda7d8c0b
2 changed files with 4 additions and 13 deletions
|
@ -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,22 +67,15 @@ data class DrawableData(val value: ByteArray, val format: DrawableFormat) {
|
|||
val bitmap = BitmapFactory.decodeByteArray(value, 0, value.size)
|
||||
BitmapDrawable(resources, bitmap)
|
||||
}
|
||||
DrawableFormat.SVG -> {
|
||||
|
||||
DrawableFormat.SVG -> {
|
||||
val svg = SVG.getFromInputStream(ByteArrayInputStream(value))
|
||||
val picture = svg.renderToPicture()
|
||||
PictureDrawable(picture).apply {
|
||||
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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue