Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -keep class android.support.graphics.drawable.** { *; }
- -keep class androidx.core.graphics.drawable.** { *; }
- -keepclassmembers class **.R$* {
- public static <fields>;
- }
- object TypeData {
- init {
- rawJsonData = " [n" +
- " {n" +
- " id: 6,n" +
- " attributes: {n" +
- " "icon" : ${R.drawable.ic_burger_menu}n" +
- " }n" +
- " },n" +
- " {n" +
- " id: 5,n" +
- " attributes: {n" +
- " "icon" : ${R.drawable.ic_burger_menu}n" +
- " }n" +
- " },n" +
- " {n" +
- " id: 4,n" +
- " attributes: {n" +
- " "icon" : ${R.drawable.ic_clock}n" +
- " }n" +
- " },n" +
- "]"
- }
- var types : List<SectionType> =
- Gson().
- fromJson<List<Type>>(
- this.rawJsonData,
- object : TypeToken<ArrayList<Type>>() {}.type
- )
- fun getTypeDetails(id : Int) : Type? {
- val index = types.indexOfFirst { it.id == id } // -1 if not found
- return if (index >= 0) {
- types[index]
- } else
- null
- }
- itemView.ic_icon_type.setImageDrawable(
- ContextCompat.getDrawable(itemView.context,
- TypeData.getTypeDetails(typeId!!)!!.attributes?.icon!!))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement