Hi,
is it good to change default implementation of Android Methods through data binding
For e.g if use this method
@BindingAdapter("android:src")
public static void setImageUrl(ImageView view, String url) {
Glide.with(view.getContext()).load(url).into(view);
}
in xml
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dip"
android:contentDescription="TODO"
android:src="@{obj.url}"
/>
g
gildor
07/23/2019, 12:49 PM
It’s pretty bad approach IMO
Much better to be explicit and use special binding name for it, like imageUrl instead of android:src
👍 3
gildor
07/23/2019, 12:50 PM
But it should work, probably you just didn’t apply databinding dependencies to kapt or kapt plugin itself
c
czuckie
07/23/2019, 1:03 PM
as a dev adopting a code base, I'd curse the guy who decided to override the default like that, just as a personal opinion
➕ 2
w
Will Shelor
07/24/2019, 2:04 AM
In this case, you're not overriding the default (which takes a drawable)- you're applying a different type (string) to the default name. I actually like this, as it doesn't pollute your autocomplete. We try to avoid overriding the default behavior, though.
Will Shelor
07/24/2019, 2:05 AM
we actually override src, but also include extra elemnts, like "placeholder" and "error"