setImageURI(url) is deprecated in Fresco. What to use instead?
Asked Answered
W

2

5

I am using Fresco Android Library to get images from URLs. The images I get without any problem, but the thing is that the setImageURI(url) is deprecated.enter image description here So I could not find what to use instead. To avoid deprecated functions usage in my code.

Waterless answered 26/1, 2018 at 15:6 Comment(0)
D
3

You can also use this method: setImageURI(String uriPath)

val uriPath = arrayList!![position].getUrl()
draweeView.setImageURI(uriPath)
Domitiladomonic answered 26/1, 2018 at 15:30 Comment(7)
It's not the same. In your method, that's taking URI as a parameter but here I am using another method that takes String as a parameter.Domitiladomonic
There are 4 overrides, are they all deprecated?Maugham
Thank you. Now it doesn't show that it is deprecated.Waterless
@ArmenHovhannisian Cool :)Domitiladomonic
However, if you are converting from Uri -> String just for the method call, you're doing unnecessary work since it's internally converted back to Uri. github.com/facebook/fresco/blob/master/drawee/src/main/java/com/… See my comment below for alternatives.Quizmaster
so what to do ? Alexander OprisnikWaterless
See my answer below, use setImageUri(uri, callerContext)Quizmaster
Q
5

SimpleDraweeView#setImageURI(Uri) is actually @undeprecated (https://github.com/facebook/fresco/blob/master/drawee/src/main/java/com/facebook/drawee/view/SimpleDraweeView.java#L117) but this command is not a standard JavaDoc command and there is no better way to undeprecate something that has been marked as deprecated in a parent class.

However, you should use SimpleDraweeView#setImageURI(Uri uri, @Nullable Object callerContext) instead. The caller context can be null or it can be additional metadata (like a String TAG that can be used to better identify where image requests are coming from).

Quizmaster answered 26/1, 2018 at 15:35 Comment(0)
D
3

You can also use this method: setImageURI(String uriPath)

val uriPath = arrayList!![position].getUrl()
draweeView.setImageURI(uriPath)
Domitiladomonic answered 26/1, 2018 at 15:30 Comment(7)
It's not the same. In your method, that's taking URI as a parameter but here I am using another method that takes String as a parameter.Domitiladomonic
There are 4 overrides, are they all deprecated?Maugham
Thank you. Now it doesn't show that it is deprecated.Waterless
@ArmenHovhannisian Cool :)Domitiladomonic
However, if you are converting from Uri -> String just for the method call, you're doing unnecessary work since it's internally converted back to Uri. github.com/facebook/fresco/blob/master/drawee/src/main/java/com/… See my comment below for alternatives.Quizmaster
so what to do ? Alexander OprisnikWaterless
See my answer below, use setImageUri(uri, callerContext)Quizmaster

© 2022 - 2024 — McMap. All rights reserved.