Hi, is it good to change default implementation of...
# android
s
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
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
But it should work, probably you just didn’t apply databinding dependencies to kapt or kapt plugin itself
c
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
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.
we actually override src, but also include extra elemnts, like "placeholder" and "error"