Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. -keep class android.support.graphics.drawable.** { *; }
  2. -keep class androidx.core.graphics.drawable.** { *; }
  3. -keepclassmembers class **.R$* {
  4. public static <fields>;
  5. }
  6.  
  7. object TypeData {
  8.  
  9. init {
  10. rawJsonData = " [n" +
  11. " {n" +
  12. " id: 6,n" +
  13. " attributes: {n" +
  14. " "icon" : ${R.drawable.ic_burger_menu}n" +
  15. " }n" +
  16. " },n" +
  17. " {n" +
  18. " id: 5,n" +
  19. " attributes: {n" +
  20. " "icon" : ${R.drawable.ic_burger_menu}n" +
  21. " }n" +
  22. " },n" +
  23. " {n" +
  24. " id: 4,n" +
  25. " attributes: {n" +
  26. " "icon" : ${R.drawable.ic_clock}n" +
  27. " }n" +
  28. " },n" +
  29. "]"
  30. }
  31.  
  32.  
  33. var types : List<SectionType> =
  34. Gson().
  35. fromJson<List<Type>>(
  36. this.rawJsonData,
  37. object : TypeToken<ArrayList<Type>>() {}.type
  38. )
  39.  
  40. fun getTypeDetails(id : Int) : Type? {
  41. val index = types.indexOfFirst { it.id == id } // -1 if not found
  42. return if (index >= 0) {
  43. types[index]
  44. } else
  45. null
  46. }
  47.  
  48. itemView.ic_icon_type.setImageDrawable(
  49. ContextCompat.getDrawable(itemView.context,
  50. TypeData.getTypeDetails(typeId!!)!!.attributes?.icon!!))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement