Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.90 KB | None | 0 0
  1. class ParticipantChip(context: Context) : Chip(context) {
  2.  
  3.     fun setParticipant(participant: Participant) {
  4.         text = if (participant.name.isEmpty()) context.getString(R.string.profile_without_public_name) else participant.name
  5.         setChipIconResource(R.drawable.ic_person_24dp)
  6.  
  7.         if (participant.imageUri.isEmpty()) return
  8.  
  9.         val futureTarget: FutureTarget<Drawable> = GlideApp.with(context)
  10.                                                             .asDrawable()
  11.                                                             .load(participant.imageUri)
  12.                                                             .apply(RequestOptions.circleCropTransform())
  13.                                                             .submit()
  14.         launch(UI) {
  15.             (chipDrawable as ChipDrawable).chipIcon = withContext(DefaultDispatcher) { futureTarget.get() }
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement