Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不支持databindin 吗? #224

Open
woshigaokun1314 opened this issue Jul 10, 2019 · 0 comments
Open

不支持databindin 吗? #224

woshigaokun1314 opened this issue Jul 10, 2019 · 0 comments

Comments

@woshigaokun1314
Copy link

@BindingAdapter(value = {"fillBannerItem", "onBannerItemClick", "onBannderItemClickPosition"}, requireAll = false)
public static void setBGABannerData(BGABanner banner, List data, final BindingCommand onBannerItemClick, final BindingCommand onBannderItemClickPosition) {

    /**
     * 设置是否开启自动轮播,需要在 setData 方法之前调用,并且调了该方法后必须再调用一次 setData 方法
     * 例如根据图片当图片数量大于 1 时开启自动轮播,等于 1 时不开启自动轮播
     */
    if (null != data)
        banner.setAutoPlayAble(data.size() > 1);

    banner.setAdapter(new BGABanner.Adapter<ImageView, AdvertiseBean>() {
        @Override
        public void fillBannerItem(BGABanner banner, ImageView itemView, @Nullable AdvertiseBean model, int position) {
            Glide.with(banner.getContext())
                    .load(model.getImages())

// .apply(new RequestOptions().placeholder(R.drawable.holder).error(R.drawable.holder).dontAnimate().centerCrop())
.into(itemView);
}

    });

    banner.setData(data, null);
    banner.setDelegate(new BGABanner.Delegate() {
        @Override
        public void onBannerItemClick(BGABanner banner, View itemView, @Nullable Object model, int position) {
            if (null != onBannerItemClick)
                onBannerItemClick.execute(model);

            if (null != onBannderItemClickPosition)
                onBannderItemClickPosition.execute(position);

        }
    });

}

做个适配器, 在适配器里加载数据 和 事件监听, 事件监听没问题,但是 图片加载, 在停顿的时候就是纯白色无图了, 自动切换下一张的时候 会显示当前的那张图,然后滑动而过, 接着停顿的那张图就还是纯白色。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant