vitorhugods / AvatarView

A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.
Apache License 2.0
549 stars 39 forks source link

How change image src? #20

Closed mohsenmoqadam closed 3 years ago

mohsenmoqadam commented 3 years ago

Dears can help me how I change image src programmatically? Suppose it is Uri and this:

avatarView.setImageURI(it)

not work😞😞😞

mohsenmoqadam commented 3 years ago

it worked:

val parcelFileDescriptor = requireContext().contentResolver.openFileDescriptor(it, "r")
val fileDescriptor: FileDescriptor = parcelFileDescriptor!!.fileDescriptor
val image = BitmapFactory.decodeFileDescriptor(fileDescriptor)
parcelFileDescriptor!!.close()
avatarView.setImageBitmap(image)
vitorhugods commented 3 years ago

AvatarView does not override setImageURI, so it shouldn't be any different from a regular ImageView.

I can't say what was the URI you were using, or what was the issue that was happening to you in specific. But good to know you got it working.

I'll close the issue now :)