Je reçois un problème intéressant. Lorsque je débogue mon application isResColorId
est false
. Malheureusement, la fonction let
est déclenchée, et je vois qwe
sur logcat.Android infixe kotlin numéro
fun drawableTint(context: Context, view: View, colorID: Int, isResColorId: Boolean = true) {
try {
val wrap = DrawableCompat.wrap(view.background)
DrawableCompat.setTint(wrap, isResColorId then let { Timber.d("qwe"); ContextCompat.getColor(context, colorID) } ?: colorID)
view.setBackgroundDrawable(wrap)
}catch (e: Resources.NotFoundException){
Timber.e(e, "c_id: $colorID coz: $isResColorId")
}
}
infix fun <T> Boolean.then(param: T): T? = if (this) param else null
Logcat:
qwe