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

使用Glide4.0有些图片无法显示 #24

Open
zhonglinhong opened this issue Aug 23, 2017 · 3 comments
Open

使用Glide4.0有些图片无法显示 #24

zhonglinhong opened this issue Aug 23, 2017 · 3 comments

Comments

@zhonglinhong
Copy link

Glide最新的4.0 apply(baseOptions)后很多图片不能加载出来,不设置则没有问题,具体代码如下。
public class PostViewHolder extends RecyclerView.ViewHolder {
private NineGridImageView mNglContent;
private TextView mTvContent;
private RequestOptions baseOptions;

    private NineGridImageViewAdapter<String> mAdapter = new NineGridImageViewAdapter<String>() {

        @Override
        protected void onDisplayImage(Context context, ImageView imageView, String s) {

            Glide.with(context).load(s).apply(baseOptions).into(imageView);

// Picasso.with(context).load(s).placeholder(R.drawable.ic_default_image).into(imageView);
}

        @Override
        protected ImageView generateImageView(Context context) {
            return super.generateImageView(context);
        }

        @Override
        protected void onItemImageClick(Context context, ImageView imageView, int index, List<String> list) {
            Toast.makeText(context, "image position is " + index, Toast.LENGTH_SHORT).show();
        }
    };

    public PostViewHolder(View itemView) {
        super(itemView);
        baseOptions = new RequestOptions()
                .dontAnimate()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .centerCrop()
                .circleCrop()
                .placeholder(R.drawable.ic_default_image)
                .error(R.drawable.ic_default_image);
        mTvContent = (TextView) itemView.findViewById(R.id.tv_content);
        mNglContent = (NineGridImageView<String>) itemView.findViewById(R.id.ngl_images);
        mNglContent.setAdapter(mAdapter);
        mNglContent.setItemImageClickListener(new ItemImageClickListener<String>() {
            @Override
            public void onItemImageClick(Context context, ImageView imageView, int index, List<String> list) {
                Log.d("onItemImageClick", list.get(index));
            }
        });
    }

    public void bind(Post post) {
        mNglContent.setImagesData(post.getImgUrlList(), post.getmSpanType());
        mTvContent.setText(post.getContent());

        Log.d("jaeger", "九宫格高度: " + mNglContent.getMeasuredHeight());
        Log.d("jaeger", "item 高度: " + itemView.getMeasuredHeight());
    }
}
@laobie
Copy link
Owner

laobie commented Aug 23, 2017

这个可能是 baseOptions 设置了某些选项导致的,你看看 log 里面有什么错误或者 warning

@zhonglinhong
Copy link
Author

好的,我先看一下

@LiJian0129
Copy link

Glide设置了placeholder,滑动后复用的view就显示placeholder图片

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

3 participants