Android Data Binding
In this series of blogs, I am going to put down my notes from learning the course 'Android Fundamentals: Data bindi...
For further actions, you may consider blocking this person and/or reporting abuse
Hi Subbu,
I'm working on AOSP internal apps and using AOSP Marshmallow version on Ubuntu 5.x. I wanted to use data binding in these apps. But here is the problem,
Whenever I build my app with databinding integration, throws a error for databinding objects and classes.
Can you help me out to understand how to build (make) databinding apps in AOSP. May be I need to specify some parameters in the make file, but I am not sure what exactly to write in make file.
Please :-)
Thanks in advance
Absolutely I love to help you in whatever way I can. Please post the error that you see when compiling the AOSP module, so that I can get a clear idea.
If you are using Marshmallow version of AOSP (I'm assuming the release version: 6.0.0_r1),
Please verify if you have either one. In my opinion, using the pre-built aar file would be simple to start with.
Hi,Subbu
As we know if compile app with android studio to support data-binding, we only need to add
in build.gralde.
But how to enable android data-binding in Android.mk if we want to compile app with AOSP? Thanks.
Hi,
What's the Android version you are using?
I’m not sure how much I can help as I haven’t done it before.
I believe DataBinding should be enabled from 'build.gradle' file. In Android.mk file, you should declare the dependencies.
Check it out this link:
androidxref.com/6.0.1_r10/xref/fra...
From my observation of this app,
It uses,
In Project level gradle file,
In App level gradle file,
By looking at the module definition of data-binding library,
androidxref.com/6.0.1_r10/xref/fra...
And something interesting I found from this SO question,
stackoverflow.com/questions/481139...
I would imagine, you might need to reference the libraries in your make file.
This is what we did in one of our apps to have appcompat support.
Similar to this there should be a way to add the DataBinding libraries as well.
Sorry It took long to respond.
HI Subbu,could you give me a demo about how to support databinding in AOSP.
Thanks very much
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?
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.
Hi KrishnaGolakoti Were you able to solve this..? i'm getting the same error
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.
Hi juliushamdali:
Could you let me know how to support databinding in AOSP?
Thanks very much.