Java Code Examples for com.bumptech.glide.request.RequestOptions#placeholder()

The following examples show how to use com.bumptech.glide.request.RequestOptions#placeholder() . 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: CrewAdapter.java    From Android with MIT License 6 votes vote down vote up
@Override
public void onBindViewHolder(CrewAdapter.CrewViewHolder holder, final int position) {

    holder.name.setText(crews.get(position).getName());
    holder.character.setText(crews.get(position).getDepartment());

    RequestOptions requestOptions = new RequestOptions();
    requestOptions.placeholder(R.drawable.if_person);
    requestOptions.error(R.drawable.if_person);
    Glide.with(mContext).setDefaultRequestOptions(requestOptions).load("http://image.tmdb.org/t/p/w185"+crews.get(position).getProfilePath()).apply(RequestOptions.circleCropTransform()).into(holder.thumbnail);


    //onClick
    //==================================================================

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

        }
    });
}
 
Example 2
Source File: ImageViewerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			options.circleCrop();
   		}
   	}

   	options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT);
   	options.placeholder(placeholder_image);
   	options.priority(Priority.HIGH);
}
 
Example 3
Source File: ImageViewerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			options.circleCrop();
   		}
   	}

   	options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT);
   	options.placeholder(placeholder_image);
   	options.priority(Priority.HIGH);
}
 
Example 4
Source File: ImageLoaderGlide.java    From LazyRecyclerAdapter with MIT License 6 votes vote down vote up
@Override
public void loadImage(Context context, LoadOption loadOption) {
    RequestOptions requestOptions = new RequestOptions();
    if (loadOption.getErrorRes() > 0) {
        requestOptions.error(loadOption.getErrorRes());
    }
    if (loadOption.getPlaceholderRes() > 0) {
        requestOptions.placeholder(loadOption.getPlaceholderRes());
    }
    requestOptions.centerCrop();
    if (loadOption.isCircleCrop()) {
        requestOptions.circleCrop();
    }
    Glide.with(context.getApplicationContext())
            .setDefaultRequestOptions(requestOptions)
            .load(loadOption.getUrl()).into(loadOption.getImageView());
}
 
Example 5
Source File: CreditsAdapter.java    From Android with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(CreditsAdapter.CreditsViewHolder holder, final int position) {

    holder.name.setText(casts.get(position).getName());
    holder.character.setText(casts.get(position).getCharacter());

    RequestOptions requestOptions = new RequestOptions();
    requestOptions.placeholder(R.drawable.if_person);
    requestOptions.error(R.drawable.if_person);
    Glide.with(mContext).setDefaultRequestOptions(requestOptions).load("http://image.tmdb.org/t/p/w185"+casts.get(position).getProfilePath()).apply(RequestOptions.circleCropTransform()).into(holder.thumbnail);


    //onClick
    //==================================================================

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Fragment fragment = new ActorFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("person_id", casts.get(position).getId());
            fragment.setArguments(bundle);
            FragmentTransaction fragmentTransaction = ((FragmentActivity)mContext).getSupportFragmentManager().beginTransaction();
            fragmentTransaction.replace(R.id.frame, fragment,TAG_ACTOR_FRAGMENT);
            fragmentTransaction.addToBackStack(MainActivity.CURRENT_TAG);
            fragmentTransaction.commit();
        }
    });
}
 
Example 6
Source File: GlideLoader.java    From XDroidMvp with MIT License 5 votes vote down vote up
private RequestOptions wrapScaleType(Options options) {
    RequestOptions request = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
            .priority(Priority.HIGH);

    if (options != null){
        if (options.scaleType != null) {
            if (options.loadingResId != Options.RES_NONE) {
                request.placeholder(options.loadingResId);
            }
            if (options.loadErrorResId != Options.RES_NONE) {
                request.error(options.loadErrorResId);
            }

            switch (options.scaleType) {
                case MATRIX:
                case FIT_XY:
                case FIT_START:
                case FIT_END:
                case CENTER:
                case CENTER_INSIDE:
                    break;

                case FIT_CENTER:
                    request.fitCenter();
                    break;

                case CENTER_CROP:
                    request.centerCrop();
                    break;
            }
        } else {
            request.centerCrop();
        }
    }else {
        request.centerCrop();
    }

    return request;
}
 
Example 7
Source File: IndexLiveHListAdapter.java    From ZhiHuIndex with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(MyHolder holder, int position) {
    RequestOptions options = new RequestOptions();
    options.placeholder(R.drawable.profile);
    Glide.with(mContext).load(Constant.headPics.get(position % 3))
            .apply(options)
            .into(holder.mImageView);
}
 
Example 8
Source File: ImageUtil.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public static void loadImage(Context context, String picUrl, int newWidth, int newHeight, Drawable holderDrawable,
                             Drawable errorDrawable, ImageView targetIv
        ,  RequestListener callback) {
    RequestBuilder requestBuilder = loadImageRequest(context, picUrl);
    RequestOptions options = new RequestOptions();
    if (newWidth > 0 && newHeight > 0) {
        options.override(newWidth,newHeight).centerCrop();
    }
    else{
        //            loadRequest.fit();
    }
    if (holderDrawable != null) {
        options.placeholder(holderDrawable);
    }
    else{
//        loadRequest.noPlaceholder();
    }
    if (errorDrawable != null) {
        options.error(errorDrawable);
    }
    options.dontAnimate();
    if (callback != null) {
        requestBuilder.listener(callback);
    }
    requestBuilder.apply(options)
            .into(targetIv);
}
 
Example 9
Source File: GlideImageLoaderStrategy.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
@Override
public void loadImage(Context context, GlideImageLoaderConfig config) {
    if (config == null || context == null) {
        return;
    }
    RequestBuilder drawableRequestBuilder;
    if (config.asGif()) {
        drawableRequestBuilder = Glide.with(context).asGif().load(config.getUrl());
    } else {
        drawableRequestBuilder = Glide.with(context).load(config.getUrl());
    }
    RequestOptions options = new RequestOptions();
    switch (config.getCacheStrategy()) {
        case GlideImageLoaderConfig.CACHE_ALL:
            options.diskCacheStrategy(DiskCacheStrategy.ALL);
            break;
        case GlideImageLoaderConfig.CACHE_NONE:
            options.diskCacheStrategy(DiskCacheStrategy.NONE);
            break;
        case GlideImageLoaderConfig.CACHE_SOURCE:
            options.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
            break;
        case GlideImageLoaderConfig.CACHE_RESULT:
            options.diskCacheStrategy(DiskCacheStrategy.DATA);
            break;
        default:
            break;
    }
    if (config.isCenterInside()) {
        options = options.fitCenter();
    } else {
        options = options.centerCrop();
    }
    if (config.getBitmapTransformation() != null) {
        options = options.transforms(config.getBitmapTransformation());
    }
    if (config.getErrorResId() != 0) {
        options = options.error(config.getErrorResId());
    }
    if (config.getPlaceHolderResId() != 0) {
        options = options.placeholder(config.getPlaceHolderResId());
    }
    if (config.getWidth() != 0 && config.getHeight() != 0) {
        options = options.override(config.getWidth(), config.getHeight());
    }


    if (config.getView() instanceof ImageView) {
        drawableRequestBuilder.apply(options).into((ImageView) config.getView());
    } else {
        drawableRequestBuilder.apply(options).into(new SimpleTarget<Drawable>() {
            @Override
            public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                if (config.getView()!=null) {
                    config.getView().setBackground(resource);
                }
            }
        });
    }
}