I have this piece of code that repeats in 3 places
if (orientation == AppConstants.LANDSCAPE) {
width =
height =
}else{
width =
height =
}
imageUrl.let {
val options = RequestOptions()
.centerCrop()
.override(width, height)
Glide.with(context)
.load(Uri.parse(imageUrl))
.apply(options)
.into(cardView.mainImageView)
}
I don't know which is the best solution to have in one place the code of calculating width and height based on orientation ? I don't think I can replace it with extension function