Search in sources :

Example 1 with ImageUrlInterface

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;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) ImageUrlInterface(com.boredream.bdcodehelper.entity.ImageUrlInterface) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) WebViewActivity(com.boredream.bdcodehelper.activity.WebViewActivity) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 WebViewActivity (com.boredream.bdcodehelper.activity.WebViewActivity)1 ImageUrlInterface (com.boredream.bdcodehelper.entity.ImageUrlInterface)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1