Ricardo C.
12/02/2020, 5:04 PMResources.getSystem()
to obtain the density for dp to px conversions? Could density “config change”?
val Int.dp: Int
get() = (this / Resources.getSystem().displayMetrics.density).toInt()
val Int.px: Int
get() = (this * Resources.getSystem().displayMetrics.density).toInt()
Ryan
12/02/2020, 5:07 PMRyan
12/02/2020, 5:07 PMRyan
12/02/2020, 5:08 PMRicardo C.
12/02/2020, 5:11 PMResources.getSystem()
, it makes the extensions so clean…Ryan
12/02/2020, 5:11 PMMarco
12/03/2020, 2:32 PMResources.getSystem()
inside a class the risk is that you can’t create unit test on it, because you are using a resource statically. This is my opinion in terms of testability.