use of com.boredream.bdcodehelper.entity.ImageUrlInterface in project bdcodehelper by boredream.
the class BannerPagerAdapter method instantiateItem.
@Override
public Object instantiateItem(ViewGroup container, final int position) {
final ImageUrlInterface image = images.get(position % images.size());
View view = View.inflate(context, R.layout.item_image_banner, null);
TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
final ImageView iv = (ImageView) view.findViewById(R.id.iv_image);
String title = image.getImageTitle();
if (TextUtils.isEmpty(title)) {
tv_title.setVisibility(View.GONE);
} else {
tv_title.setVisibility(View.VISIBLE);
tv_title.setText(title);
}
final String url = image.getImageUrl();
Glide.with(context).load(url).apply(new RequestOptions().centerCrop()).into(iv);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onBannerClickListener != null) {
onBannerClickListener.onOnClick(position % images.size());
} else {
if (!TextUtils.isEmpty(image.getImageLink())) {
Intent intent = new Intent(context, WebViewActivity.class);
intent.putExtra("title", image.getImageTitle());
intent.putExtra("url", image.getImageLink());
context.startActivity(intent);
} else {
ImageBrowserActivity.start(context, images, position % images.size());
}
}
}
});
container.addView(view);
return view;
}
Aggregations