Skip to content

Instantly share code, notes, and snippets.

@dadouf
Created December 11, 2020 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadouf/9589a25cfa65c1f155b6a1fd871d4eeb to your computer and use it in GitHub Desktop.
Save dadouf/9589a25cfa65c1f155b6a1fd871d4eeb to your computer and use it in GitHub Desktop.
private var hasInitParentDimensions = false
private var maxImageWidth: Int = 0
private var maxImageHeight: Int = 0
private var maxImageAspectRatio: Float = 1f
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
if (!hasInitParentDimensions) {
maxImageWidth = parent.width
maxImageHeight = parent.height
maxImageAspectRatio = maxImageWidth.toFloat() / maxImageHeight.toFloat()
hasInitParentDimensions = true
}
return VH(ImageView(parent.context))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment