Skip to content

Instantly share code, notes, and snippets.

View zihadrizkyef's full-sized avatar
🎯
Focusing

Zihad Rizky Edwin Fikri zihadrizkyef

🎯
Focusing
  • Olsera
  • DI Yogyakarta
View GitHub Profile
@zihadrizkyef
zihadrizkyef / Extension.kt
Last active February 7, 2022 07:16
Load image with placeholder. If fails, show text describing the image
fun ImageView.loadImageOrInitial(
url: String?,
text: String?,
textSize: Float = 16F,
textColor: Int = Color.BLACK,
backgroundColor: Int = Color.WHITE,
maxChar: Int = 2,
allCaps: Boolean = true,
progressStroke: Float = 5F,
progressRadius: Float = 30F,
@zihadrizkyef
zihadrizkyef / Main.kt
Created August 29, 2018 04:02
Html.fromhtml ImageGetter example
val imageGetter = Html.ImageGetter {
val levelListDrawable = LevelListDrawable()
val drawable = context.resources.getDrawable(R.drawable.ic_book)
levelListDrawable.addLevel(1, 1, drawable)
val displayMetrics = DisplayMetrics()
(context as Activity).windowManager.defaultDisplay.getMetrics(displayMetrics)
val widthImg = displayMetrics.widthPixels
val heightImg = widthImg/3*2