DEV Community

Discussion on: Android Data Binding

Collapse
 
juliushamdali profile image
juliushamdali

hi Subbu, been going thru yo article i am playing around with the data binding library , very interesting and it eliminates a lot of boilerplate code. i ve also managed to use ImageBindingAdapter like below to get images from an api that simply take the end url as /fdfdgytedgda.jpg so far so good.

public final class ImageBindingAdapter {
@BindingAdapter(value = "imageUrl")
public static void loadImageUrl(ImageView view, String url) {
if (url != null && !url.equals(""))
Picasso.with(view.getContext())
.load(Constant.IMAGE_ENDPOINT_PREFIX + url)
.placeholder(R.drawable.placeholder)
.into(view);
}

No problem at all with the above, but i have a scenario that seems un-obvious
to me that the requirement is to fetch images by size as small medium or large. the images are only identified with image ID like 34231214 which is saved in sqlite that requires specifying the size as picture_size=large when fetching. how can this be handled the endpoint is say subbramanil.com/api/pictures/232242/picture_size=large .where does the binding of the picture_size=large take place?

Collapse
 
subbramanil profile image
Subbu Lakshmanan

Hi Buddy,

That's an interesting requirement. Have you checked this answer by Jake Wharton?

Question - How to pass additional context information for a custom Downloader.

The idea is to create a custom URI and pass it to Picasso also configure Picasso to use a custom downloader that knows how to parse the response.

Good luck!! Check it out and let me know how it goes.

P.S: I am in a it tight spot at work, otherwise I would love to help you out.

Collapse
 
krishnagolakoti profile image
KrishnaGolakoti

Hi Juliushamdali,

Could you please let me know if you were able to use data binding in AOSP? I'm also trying to include this, but using of <data tags, <variable name, type attributes are not getting resolved in xml to generate the code.

Collapse
 
riatauro profile image
riatauro • Edited

Hi KrishnaGolakoti Were you able to solve this..? i'm getting the same error

Collapse
 
sankes profile image
shankes

Hi juliushamdali:
Could you let me know how to support databinding in AOSP?
Thanks very much.