Skip to content

Instantly share code, notes, and snippets.

@faridfor
Created March 2, 2020 09:38
Show Gist options
  • Save faridfor/fae98d5558215d22610f16d0b2bc8981 to your computer and use it in GitHub Desktop.
Save faridfor/fae98d5558215d22610f16d0b2bc8981 to your computer and use it in GitHub Desktop.
fun showSigners(document: Document) {
ceremony_holder.removeAllViews()
val ceremonies = document.ceremonies?.sortedBy { it.order } ?: return
val holderWidth = ceremony_holder.width
val cellSize = resources.getDimensionPixelSize(R.dimen.document_image_size)
val count = holderWidth / cellSize
if (ceremonies.size > count) {
has_more.visibility = View.VISIBLE
has_more.text = "+${ceremonies.size - count}"
} else has_more.visibility = View.INVISIBLE
var addedViewsCount = 0
for (ceremony in ceremonies) {
val imageView = LayoutInflater.from(context).inflate(R.layout.row_single_signer, ceremony_holder, false) as CircleTextImageView
imageView.apply {
setName(ceremony.firstName, ceremony.lastName)
setImageResource(if (document.hasNidSigned(ceremony)) R.color.primary else R.color.unsigned_color)
}
ceremony_holder.addView(imageView)
addedViewsCount++
if (addedViewsCount == count)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment