Search in sources :

Example 1 with BannerModel

use of cn.bingoogolapple.refreshlayout.demo.model.BannerModel in project BGARefreshLayout-Android by bingoogolapple.

the class DataEngine method getCustomHeaderView.

public static View getCustomHeaderView(final Context context) {
    View headerView = View.inflate(context, R.layout.view_custom_header, null);
    final BGABanner banner = (BGABanner) headerView.findViewById(R.id.banner);
    banner.setAdapter(new BGABanner.Adapter<ImageView, String>() {

        @Override
        public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
            Glide.with(itemView.getContext()).load(model).placeholder(R.mipmap.holder).error(R.mipmap.holder).dontAnimate().centerCrop().into(itemView);
        }
    });
    banner.setDelegate(new BGABanner.Delegate<ImageView, String>() {

        @Override
        public void onBannerItemClick(BGABanner banner, ImageView imageView, String model, int position) {
            Toast.makeText(banner.getContext(), "点击了第" + (position + 1) + "页", Toast.LENGTH_SHORT).show();
        }
    });
    App.getInstance().getEngine().getBannerModel().enqueue(new Callback<BannerModel>() {

        @Override
        public void onResponse(Call<BannerModel> call, Response<BannerModel> response) {
            BannerModel bannerModel = response.body();
            banner.setData(R.layout.view_image, bannerModel.imgs, bannerModel.tips);
        }

        @Override
        public void onFailure(Call<BannerModel> call, Throwable t) {
        }
    });
    return headerView;
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) ImageView(android.widget.ImageView) BannerModel(cn.bingoogolapple.refreshlayout.demo.model.BannerModel) BGABanner(cn.bingoogolapple.bgabanner.BGABanner)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)1 BannerModel (cn.bingoogolapple.refreshlayout.demo.model.BannerModel)1