Java Code Examples for com.bumptech.glide.DrawableRequestBuilder#into()

The following examples show how to use com.bumptech.glide.DrawableRequestBuilder#into() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GankAdapter.java    From GankGirl with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    GankBean gankBean = mData.get(position);
    holder.tvHomeGankTitle.setText(gankBean.desc);
    holder.tvHomeGankAuthor.setText(gankBean.who);
    holder.tvHomeGankDate.setText(DateUtils.formatDateDetailDay(DateUtils.parseStringToDate(gankBean.publishedAt)));

    if (gankBean.images != null && !gankBean.images.isEmpty()) {
        holder.ivHomeGankImg.setVisibility(View.VISIBLE);
        DrawableRequestBuilder<String> requestBuilder = Glide.with(mContext)
                .load(gankBean.images.get(0)+"?imageView2/0/w/400")
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .error(R.color.accent)
                .crossFade();
        requestBuilder.into(holder.ivHomeGankImg);
    }else {
        holder.ivHomeGankImg.setVisibility(View.GONE);
    }
}
 
Example 2
Source File: PostAdapter.java    From materialup with MIT License 6 votes vote down vote up
@Override
public void onBindViewHolder(PostViewHolder holder, int position) {
    final Post post = posts.get(position);
    holder.title.setText(post.getTitle());

    DrawableRequestBuilder<String> request = Glide.with(context)
            .load(post.getImage_url());
    if (post.getImage_url().endsWith(".gif")) {
        request.diskCacheStrategy(DiskCacheStrategy.SOURCE).into(holder.artwork);
    } else {
        request.into(holder.artwork);
    }
    holder.title.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(post.getUrl()));
            context.startActivity(i);

        }
    });
}
 
Example 3
Source File: NetImageView.java    From Alibaba-Android-Certification with MIT License 5 votes vote down vote up
/**
 *
 * @param uri
 * @param defDrawable
 * @param mTransformation       自定义Bitmap
 */
public void load(String uri, int defDrawable, BitmapTransformation mTransformation){
    DrawableRequestBuilder<String> builder=Glide.with(getContext()).load(uri).placeholder(defDrawable);
    //监听
    if(mListener!=null){
        builder.listener(mListener);
    }
    //特殊图像
    if(mTransformation!=null){
        builder.transform(mTransformation).into(this);
    }else{
        builder.into(this);
    }
}
 
Example 4
Source File: ImageLoader.java    From AccountBook with GNU General Public License v3.0 5 votes vote down vote up
private void loadImageView(Object object, int placeholderId, int errorId, Transformation transform, ImageView imageView){
    DrawableRequestBuilder builder = load(object, with());
    if(builder != null){
        // 设置占位图
        if(placeholderId != -1) builder.placeholder(placeholderId);
        // 设置加载错误时占位图
        if(errorId != -1)       builder.error(errorId);
        // 设置 transform
        if(transform != null)   builder.bitmapTransform(transform);
        // 加载到图片
        builder.into(imageView);
    }
}
 
Example 5
Source File: GlideImageLoader.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 下载图片转换圆角
 * @param context
 * @param imageRes
 * @param view
 * @param radius 圆角度
 */
public static void loadAdapterRadius(Context context, String imageRes, ImageView view,int radius){
    DrawableRequestBuilder requestBuilder = Glide.with(context)
            .load(imageRes)
            .centerCrop()
            .crossFade()
            .transform(new GlideRoundTransform(context, radius))
            .diskCacheStrategy(DiskCacheStrategy.ALL);
    requestBuilder.into(view);
}
 
Example 6
Source File: GlideImageLoader.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 下载图片转换圆角
 * @param context
 * @param imageRes
 * @param view
 * @param radius
 */
public static void loadAdapterRadius(Context context, @DrawableRes int imageRes, ImageView view, int radius){
    DrawableRequestBuilder requestBuilder = Glide.with(context)
            .load(imageRes)
            .centerCrop()
            .crossFade()
            .transform(new GlideRoundTransform(context, radius))
            .diskCacheStrategy(DiskCacheStrategy.ALL);
    requestBuilder.into(view);
}
 
Example 7
Source File: AboutActivity.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
private void bindLibrary(final LibraryHolder holder, final Library lib) {
    holder.name.setText(lib.name);
    holder.description.setText(lib.description);
    DrawableRequestBuilder<String> request = Glide.with(holder.image.getContext())
            .load(lib.imageUrl)
            .placeholder(R.drawable.avatar_placeholder);
    if (lib.circleCrop) {
        request.transform(circleCrop);
    }
    request.into(holder.image);
}
 
Example 8
Source File: PhotoViewWrapper.java    From react-native-image-zoom with MIT License 4 votes vote down vote up
public void setSource(ReadableMap params) {
    mParams = params;
    @Nullable Uri mUri = null;

    String source = params.hasKey("uri") ? params.getString("uri") : null;
    String thumbnail = params.hasKey("thumbnail") ? params.getString("thumbnail") : null;
    ReadableMap headers = params.hasKey("headers") ? params.getMap("headers") : null;

    //handle base64
    if (source.startsWith("data:image/png;base64,")){
        Glide
            .with(this.getContext())
            .load(Base64.decode(source.replaceAll("data:image\\/.*;base64,", ""), Base64.DEFAULT))
            .into(this)
        ;
        return;
    }

    boolean useStorageFile = false ;

    // handle bundled app resources
    try {
        mUri = Uri.parse(source);
        // Verify scheme is set, so that relative uri (used by static resources) are not handled.
        if (mUri.getScheme() == null) {
            mUri = null;
        } else if(
            !mUri.getScheme().equals("http") &&
            !mUri.getScheme().equals("https")
        ){
            useStorageFile = true ;

            if (!mInitialized) {
                this.setImageURI(mUri);
            }
        }
    } catch (Exception e) {
        // ignore malformed uri, then attempt to extract resource ID.
    }

    if (mUri == null) {
        mUri = mResourceDrawableIdHelper.getResourceDrawableUri(
            this.getContext(),
            source
        );
        Glide
            .with(this.getContext())
            .load(mUri)
            .into(this);
    } else if (useStorageFile) {
        Glide
            .with(this.getContext())
            .load(mUri)
            .into(this);
    } else {
        // Handle an http / https address
        RequestListener listener = this.getRequestListener();

        LazyHeaders.Builder lazyHeaders = new LazyHeaders.Builder();
        Log.d("null headers", String.valueOf(headers != null));
        if(headers != null){
            ReadableMapKeySetIterator it = headers.keySetIterator();
            Log.d("next headers", String.valueOf(it.hasNextKey()));
            while(it.hasNextKey()){
                String Key = it.nextKey();
                lazyHeaders.addHeader(Key, headers.getString(Key));
            }
        }

        Log.d("thing", mUri.toString());
        DrawableRequestBuilder builder = Glide
                .with(this.getContext())
                .load(new GlideUrl(mUri.toString(), lazyHeaders.build()))
                .listener(listener);

        //set thumbnails
        if(thumbnail != null) {
            DrawableRequestBuilder<String> thumbnailRequest = Glide
                    .with(this.getContext())
                    .load(thumbnail);
            builder = builder.thumbnail(thumbnailRequest);
        }

        builder.into(this);
    }

    this.setChangeListeners();
}