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;
}
Aggregations