How do I access an instance variable inside a BindingAdapter when using Android Data Binding?

不羁的心 提交于 2019-11-29 14:20:10

Put whole movie instace through custom biding adapter:

 <ImageView
        android:layout_width="match_parent"
        android:layout_height="150dp""
        app:movie="@{movie}"
        />

The Binding Adapter:

class Movie{
boolean isLoaded;

@BindingAdapter({"movie"})
    public static void loadImage(final ImageView view, final Movie movie) {
        if(movie != null && moview.getImageUrl() != null){
          Picasso.with(view.getContext())
             .load(movie.getImageUrl())
             .into(view, new Callback.EmptyCallback() {
             @Override public void onSuccess() {
                 image.setLoaded(true);
             });
     }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!