com.bumptech.glide.request.RequestOptions Java Examples

The following examples show how to use com.bumptech.glide.request.RequestOptions. 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: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupGlideOptions() {
   	options = new RequestOptions();
   	int size;

   	if (isShapeCircle) {
   		if (Defaults.CIRCLE_RADIUS > 0) {
   			size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
   			options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS));

   		} else {
   			size = Defaults.IMAGE_HEIGHT;
   			options.circleCrop();
   		}

   	} else {
   		size = (int) (0.65 * Defaults.IMAGE_HEIGHT);
   	}

   	options.override(size, size);
   	options.error(error_image);
   	options.priority(Priority.HIGH);
   }
 
Example #2
Source File: GlideUtils.java    From Collection-Android with MIT License 6 votes vote down vote up
/**
 * 处理Glide You cannot start a load for a destroyed activity问题
 *
 * @param context
 * @param url               网络图片
 * @param defaultLoadingImg 默认加载图片
 * @param imageView
 */
public static void loadImg(Context context, String url, int defaultLoadingImg, ImageView imageView) {
	try {
		RequestOptions options = new RequestOptions()
				.placeholder(defaultLoadingImg)
				.error(defaultLoadingImg)
				.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
				.priority(Priority.HIGH);

		Glide.with(context)
				.load(url)
				.apply(options)
				.into(imageView);

	} catch (Exception exception) {
		return;
	}
}
 
Example #3
Source File: GlideEngine.java    From react-native-syan-image-picker with MIT License 6 votes vote down vote up
/**
 * 加载相册目录
 *
 * @param context   上下文
 * @param url       图片路径
 * @param imageView 承载图片ImageView
 */
@Override
public void loadFolderImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
    Glide.with(context)
            .asBitmap()
            .load(url)
            .override(180, 180)
            .centerCrop()
            .sizeMultiplier(0.5f)
            .apply(new RequestOptions().placeholder(R.drawable.picture_image_placeholder))
            .into(new BitmapImageViewTarget(imageView) {
                @Override
                protected void setResource(Bitmap resource) {
                    RoundedBitmapDrawable circularBitmapDrawable =
                            RoundedBitmapDrawableFactory.
                                    create(context.getResources(), resource);
                    circularBitmapDrawable.setCornerRadius(8);
                    imageView.setImageDrawable(circularBitmapDrawable);
                }
            });
}
 
Example #4
Source File: VideoCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
CardViewHolder(ImageCardView view, Context context) {
    super(view);
    mContext = context;
    Context wrapper = new ContextThemeWrapper(mContext, R.style.MyPopupMenu);
    mPopupMenu = new PopupMenu(wrapper, view);
    mPopupMenu.inflate(R.menu.popup_menu);

    mPopupMenu.setOnMenuItemClickListener(this);
    view.setOnLongClickListener(this);

    mOwner = (LifecycleOwner) mContext;

    mDefaultBackground = mContext.getResources().getDrawable(R.drawable.no_cache_no_internet, null);
    mDefaultPlaceHolder = new RequestOptions().
            placeholder(mDefaultBackground);

    mCardView = (ImageCardView) CardViewHolder.this.view;
    Resources resources = mCardView.getContext().getResources();
    mCardView.setMainImageDimensions(Math.round(
            resources.getDimensionPixelSize(R.dimen.card_width)),
            resources.getDimensionPixelSize(R.dimen.card_height));

    mFragmentActivity = (FragmentActivity) context;
    mViewModel = ViewModelProviders.of(mFragmentActivity).get(VideosViewModel.class);
}
 
Example #5
Source File: MediaPlayerPop.java    From a with GNU General Public License v3.0 6 votes vote down vote up
public void setCover(String coverPath) {
    if (TextUtils.isEmpty(coverPath)) return;
    if (coverPath.startsWith("http")) {
        Glide.with(this).load(coverPath)
                .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .placeholder(R.drawable.img_cover_default))
                .into(ivCover);
        Glide.with(this).load(coverPath)
                .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .placeholder(R.drawable.img_cover_gs))
                .apply(RequestOptions.bitmapTransform(new BlurTransformation(getContext(), 25)))
                .into(ivCoverBg);
    } else {
        File file = new File(coverPath);
        Glide.with(this).load(file)
                .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .placeholder(R.drawable.img_cover_default))
                .into(ivCover);
        Glide.with(this).load(file)
                .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .placeholder(R.drawable.img_cover_gs))
                .apply(RequestOptions.bitmapTransform(new BlurTransformation(getContext(), 25)))
                .into(ivCoverBg);
    }
}
 
Example #6
Source File: DownloadAdapter.java    From a with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position, @NonNull List<Object> payloads) {
    final DownloadBookBean item = data.get(holder.getLayoutPosition());
    if (!payloads.isEmpty()) {
        holder.tvName.setText(String.format(Locale.getDefault(), "%s(正在下载)", item.getName()));
        holder.tvDownload.setText(activity.getString(R.string.un_download, (Integer) payloads.get(0)));
    }else {
        holder.ivDel.getDrawable().mutate();
        holder.ivDel.getDrawable().setColorFilter(activity.getResources().getColor(R.color.tv_text_default), PorterDuff.Mode.SRC_ATOP);
        Glide.with(activity)
                .load(item.getCoverUrl())
                .apply(new RequestOptions()
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .dontAnimate().placeholder(R.drawable.img_cover_default)
                        .error(R.drawable.img_cover_default))
                .into(holder.ivCover);
        if (item.getSuccessCount() > 0) {
            holder.tvName.setText(String.format(Locale.getDefault(), "%s(正在下载)", item.getName()));
        } else {
            holder.tvName.setText(String.format(Locale.getDefault(), "%s(等待下载)", item.getName()));
        }
        holder.tvDownload.setText(activity.getString(R.string.un_download, item.getDownloadCount() - item.getSuccessCount()));
        holder.ivDel.setOnClickListener(view -> DownloadService.removeDownload(activity, item.getNoteUrl()));
    }
}
 
Example #7
Source File: VideoDetailsFragment.java    From androidtv-Leanback with Apache License 2.0 6 votes vote down vote up
private void updateBackground(String uri) {
    RequestOptions options = new RequestOptions()
            .centerCrop()
            .error(mDefaultBackground);

    Glide.with(this)
            .asBitmap()
            .load(uri)
            .apply(options)
            .into(new SimpleTarget<Bitmap>(mMetrics.widthPixels, mMetrics.heightPixels) {
                @Override
                public void onResourceReady(
                        Bitmap resource,
                        Transition<? super Bitmap> transition) {
                    mBackgroundManager.setBitmap(resource);
                }
            });
}
 
Example #8
Source File: FileExpandableAdapter.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
protected void setChildViewThumb(FileUtil.MediaFileType type, String f, ImageView icon, RequestOptions options) {
    if (type == FileUtil.MediaFileType.MOVIE ||
            type == FileUtil.MediaFileType.IMG) {
        if (options == null) {
            Glide.with(mContext).load(f).listener(mRequestListener).into(icon);
        } else {
            Glide.with(mContext).load(f).listener(mRequestListener).apply(options).into(icon);
        }
    } else if (type == FileUtil.MediaFileType.APP) {
        Bitmap b = sLruCache.get(f);
        if (b == null) {
            AppThumbTask task = new AppThumbTask(sLruCache, mContext, icon);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new File(f));
        } else
            icon.setImageBitmap(b);
    } else if (type == FileUtil.MediaFileType.MP3) {
        icon.setImageResource(R.mipmap.music);
    } else if (type == FileUtil.MediaFileType.DOC) {
        icon.setImageResource(R.mipmap.document);
    } else if (type == FileUtil.MediaFileType.RAR) {
        icon.setImageResource(R.mipmap.rar);
    }
}
 
Example #9
Source File: BookInfoEditActivity.java    From a with GNU General Public License v3.0 6 votes vote down vote up
private void initCover() {
    if (!this.isFinishing() && book != null) {
        if (TextUtils.isEmpty(book.getCustomCoverPath())) {
            Glide.with(this).load(book.getBookInfoBean().getCoverUrl())
                    .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                            .placeholder(R.drawable.img_cover_default)).into(ivCover);
        } else if (book.getCustomCoverPath().startsWith("http")) {
            Glide.with(this).load(book.getCustomCoverPath())
                    .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                            .placeholder(R.drawable.img_cover_default)).into(ivCover);
        } else {
            Glide.with(this).load(new File(book.getCustomCoverPath()))
                    .apply(new RequestOptions().dontAnimate().diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                            .placeholder(R.drawable.img_cover_default)).into(ivCover);
        }
    }
}
 
Example #10
Source File: VideoFragment.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mPlayVideoIcon.setOnClickListener(v -> {
        Uri uri = StorageHelper.getUriForFile(getContext(), media.getFile());
        Intent intent = new Intent(Intent.ACTION_VIEW).setDataAndType(uri, media.getMimeType());
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(intent);
    });

    // TODO: See where we can move this. Seems like boilerplate code that belongs in
    // a utility class or Builder of some sort.
    RequestOptions options =
            new RequestOptions().signature(media.getSignature()).centerCrop()
                    .diskCacheStrategy(
                            DiskCacheStrategy.AUTOMATIC);

    Glide.with(getContext()).load(media.getUri()).apply(options).into(previewView);
    setTapListener(previewView);
}
 
Example #11
Source File: ImageUtils.java    From SendBird-Android with MIT License 6 votes vote down vote up
/**
 * Crops image into a circle that fits within the ImageView.
 */
public static void displayRoundImageFromUrl(final Context context, final String url, final ImageView imageView) {
    RequestOptions myOptions = new RequestOptions()
            .centerCrop()
            .dontAnimate();

    Glide.with(context)
            .asBitmap()
            .apply(myOptions)
            .load(url)
            .into(new BitmapImageViewTarget(imageView) {
                @Override
                protected void setResource(Bitmap resource) {
                    RoundedBitmapDrawable circularBitmapDrawable =
                            RoundedBitmapDrawableFactory.create(context.getResources(), resource);
                    circularBitmapDrawable.setCircular(true);
                    imageView.setImageDrawable(circularBitmapDrawable);
                }
            });
}
 
Example #12
Source File: StaggeredRecyclerViewAdapter.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(MyHolder holder, final int position) {
    ViewGroup.LayoutParams params = holder.mImageView.getLayoutParams();
    params.height = heights.get(position);
    holder.mImageView.setLayoutParams(params);

    Glide.with(mContext).
            load(demos.get(position))
            .apply(new RequestOptions().placeholder(R.drawable.a6))
            .into(holder.mImageView);
    holder.itemshell.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });
}
 
Example #13
Source File: DownloadAdapter.java    From HaoReader with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position, @NonNull List<Object> payloads) {
    final DownloadBookBean item = dataS.get(holder.getLayoutPosition());
    if (!payloads.isEmpty()) {
        holder.tvName.setText(String.format(Locale.getDefault(), "[正在下载]%s", item.getName()));
        holder.tvName.getPaint().setFakeBoldText(true);
        holder.tvDownload.setText(activity.getString(R.string.un_download, (Integer) payloads.get(0)));
    } else {
        Glide.with(activity)
                .load(item.getCoverUrl())
                .apply(new RequestOptions()
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE).centerCrop()
                        .dontAnimate().placeholder(R.drawable.img_cover_default)
                        .error(R.drawable.img_cover_default))
                .into(holder.ivCover);
        if (item.getSuccessCount() > 0) {
            holder.tvName.setText(String.format(Locale.getDefault(), "[正在下载]%s", item.getName()));
            holder.tvName.getPaint().setFakeBoldText(true);
        } else {
            holder.tvName.setText(String.format(Locale.getDefault(), "[等待下载]%s", item.getName()));
            holder.tvName.getPaint().setFakeBoldText(false);
        }
        holder.tvDownload.setText(activity.getString(R.string.un_download, item.getDownloadCount() - item.getSuccessCount()));
        holder.ivDel.setOnClickListener(view -> DownloadService.removeDownload(activity, item.getNoteUrl()));
    }
}
 
Example #14
Source File: NewTodoActivity.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
private void initHeadImage(){

        Random random = new Random();
        imgId = imageArray[random.nextInt(8)];
        RequestOptions options = new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .skipMemoryCache(true);
        Glide.with(getApplicationContext())
                .load(imgId)
                .apply(options)
                .into(new_bg);

    }
 
Example #15
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load(final Context context) {
	Glide
			.with(this)
			.load("http://via.placeholder.com/350x150")
			.apply(new RequestOptions()
					.diskCacheStrategy(DiskCacheStrategy.NONE) // force reload
					.skipMemoryCache(true) // force reload
			)
			.listener(new LoggingListener<Drawable>())
			.into(imageView)
	;
}
 
Example #16
Source File: GlideLoader.java    From XDroidMvp with MIT License 5 votes vote down vote up
@Override
public void loadCorner(String url, final ImageView target, int radius, Options options) {
    RequestOptions requestOptions = wrapScaleType(options);

    //设置图片圆角角度
    MultiTransformation multiTransformation = new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCorners(radius));
    requestOptions.transform(multiTransformation);

    getRequestManager(target.getContext())
            .load(url)
            .apply(requestOptions)
            .transition(withCrossFade())
            .into(target);

}
 
Example #17
Source File: AlbumViewHolder.java    From klingar with Apache License 2.0 5 votes vote down vote up
@Override void bindModel(@NonNull Album album) {
  title.setText(album.title());

  //noinspection SuspiciousNameCombination
  Glide.with(itemView.getContext())
      .load(Urls.addTranscodeParams(album.thumb(), height, height))
      .apply(RequestOptions.centerCropTransform())
      .transition(withCrossFade())
      .into(thumb);

  subtitle.setText(album.artistTitle());
}
 
Example #18
Source File: PhotosActivity.java    From BaldPhone with Apache License 2.0 5 votes vote down vote up
@Override
protected void setupBeforeAdapter() {
    requestOptions = new RequestOptions()
            .override(width)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .error(R.drawable.error_on_background)
            .lock();
}
 
Example #19
Source File: MyReviewAdapter.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
private void createImage(MyCommentListResp.CommentInfoBean commentInfoBean,
                         TagFlowLayout tagFlow) {

    List<ArticleReviewResp.ImageUrlBean> imageUrl = commentInfoBean.getImageUrl();

    if (imageUrl == null || imageUrl.size() <= 0) {
        tagFlow.setVisibility(View.GONE);
        return;
    }

    tagFlow.removeAllViews();
    tagFlow.setVisibility(View.VISIBLE);

    for (ArticleReviewResp.ImageUrlBean imageUrlBean : imageUrl) {
        View item = mInflater
                .inflate(R.layout.widget_review_image, tagFlow, false);

        ImageView ivImage = item.findViewById(R.id.iv_image);

        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.drawable.placeholder_loading_large)
                .error(R.drawable.placeholder_error_large);

        TyUtils.getGlideRequest(
                mFragment.get(),
                mContext.get(),
                imageUrlBean.getUrl(),
                requestOptions,
                ivImage);

        // 将 item 添加进流式布局
        tagFlow.addView(item);
    }

}
 
Example #20
Source File: PostTextActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
private void displaySubredditIcon() {
    if (iconUrl != null && !iconUrl.equals("")) {
        mGlide.load(iconUrl)
                .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
                .error(mGlide.load(R.drawable.subreddit_default_icon)
                        .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
                .into(iconGifImageView);
    } else {
        mGlide.load(R.drawable.subreddit_default_icon)
                .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
                .into(iconGifImageView);
    }
}
 
Example #21
Source File: CustomImgPickerPresenter.java    From YImagePicker with Apache License 2.0 5 votes vote down vote up
@Override
public void displayImage(View view, ImageItem item, int size, boolean isThumbnail) {
    Object object = item.getUri() != null ? item.getUri() : item.path;

    Glide.with(view.getContext()).load(object).apply(new RequestOptions()
            .format(isThumbnail ? DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888))
            .override(isThumbnail ? size : Target.SIZE_ORIGINAL)
            .into((ImageView) view);
}
 
Example #22
Source File: GlideManager.java    From TitleBarView with Apache License 2.0 5 votes vote down vote up
private static RequestOptions getRequestOptions() {
    RequestOptions requestOptions = new RequestOptions()
            .centerCrop() // 填充方式
            .priority(Priority.HIGH) //优先级
            .diskCacheStrategy(DiskCacheStrategy.ALL); //缓存策略
    return requestOptions;
}
 
Example #23
Source File: UserDataActivity.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
/**
 * Glide图片加载
 */
private void glideLoad(){

    RequestOptions options_1 = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .signature(new ObjectKey(SPUtils.get(UserDataActivity.this,"head_signature","")))
            .placeholder(R.drawable.default_photo);

    RequestOptions options_2 = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .signature(new ObjectKey(SPUtils.get(UserDataActivity.this,"head_signature","")))
            .placeholder(R.drawable.ic_img1);

    Glide.with(getApplicationContext())
            .load(SPUtils.get(UserDataActivity.this, "path" ,""))
            .apply(options_1)
            .into(toolbar_userhead);

    Glide.with(getApplicationContext())
            .load(SPUtils.get(UserDataActivity.this, "path" ,""))
            .apply(options_1)
            .into(user_head);

    Glide.with(getApplicationContext())
            .load(SPUtils.get(UserDataActivity.this, "path" ,""))
            .apply(bitmapTransform(new BlurTransformation(25, 3)))
            .apply(options_2)
            .into(top_bg);
}
 
Example #24
Source File: GlideUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 图片加载
 * @param uri     Image Uri
 * @param target  {@link Target}
 * @param options {@link RequestOptions}
 */
public void loadImageDrawable(final String uri, final Target<Drawable> target, final RequestOptions options) {
    if (mRequestManager != null) {
        if (options != null) {
            mRequestManager.asDrawable().load(uri).apply(options).into(target);
        } else {
            mRequestManager.asDrawable().load(uri).into(target);
        }
    }
}
 
Example #25
Source File: GlideUtil.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
public static void loadUserHeadImg(Context context, String url, ImageView imageView) {
    if (null == userHeadImgOptions) {
        userHeadImgOptions = new RequestOptions()
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .placeholder(R.drawable.icon_user)
                .error(R.drawable.icon_user);
    }
    Glide.with(context)
            .load(url)
            .apply(userHeadImgOptions)
            .into(imageView);
}
 
Example #26
Source File: MyDappsListAdapter.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull MyDappsListAdapter.ViewHolder viewHolder, int i) {
    DApp dApp = data.get(i);
    String visibleUrl = null;
    try {
        visibleUrl = Utils.getDomainName(dApp.getUrl());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    viewHolder.name.setText(dApp.getName());
    viewHolder.url.setText(visibleUrl);

    String favicon;
    if (visibleUrl != null) {
        favicon = DappBrowserUtils.getIconUrl(visibleUrl);
        Glide.with(viewHolder.icon.getContext())
                .load(favicon)
                .apply(new RequestOptions().circleCrop())
                .apply(new RequestOptions().placeholder(R.drawable.ic_logo))
                .into(viewHolder.icon);

        viewHolder.icon.setOnClickListener(v -> {
            listener.onDappClick(dApp);
        });
    }

    viewHolder.remove.setOnClickListener(v -> onDappRemovedListener.onDappRemoved(dApp));

    viewHolder.edit.setOnClickListener(v -> onDappEditedListener.onDappEdited(dApp));
}
 
Example #27
Source File: PersonalFragment.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public void initView() {
    if (AppConfig.getInstance().isLogin()) {
        loginButton.setVisibility(View.GONE);
        RequestOptions options = new RequestOptions()
                .error(R.mipmap.default_image)
                .placeholder(R.mipmap.default_image);

        Glide.with(this)
                .load(AppConfig.getInstance().getUserImage())
                .apply(options)
                .transition((DrawableTransitionOptions.withCrossFade()))
                .into(userImageIv);
        userNameTv.setText(AppConfig.getInstance().getUserScreenName());
    } else {
        loginButton.setVisibility(View.VISIBLE);
    }

    if (isLoadedSkin()) {
        skinIv.setImageResource(R.mipmap.ic_skin_light);
        skinTv.setTextColor(CommonUtils.getResColor(R.color.immutable_text_orange));
        skinTv.setText("日间模式");
    } else {
        skinIv.setImageResource(R.mipmap.ic_skin_dark);
        skinTv.setTextColor(CommonUtils.getResColor(R.color.immutable_text_black));
        skinTv.setText("夜间模式");
    }
}
 
Example #28
Source File: GlideUtil.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
/**
 * 加载圆角封面,默认4dp
 */
public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView) {
    Glide.with(context)
            .load(imgUrl)
            .apply(new RequestOptions().error(R.drawable.icon_user))
            .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(),
                    new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0))))
            .into(imageView);
}
 
Example #29
Source File: SampleCoverVideo.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
public void loadCoverImage(String url, int res) {
    mCoverOriginUrl = url;
    mDefaultRes = res;
    Glide.with(getContext().getApplicationContext())
            .setDefaultRequestOptions(
                    new RequestOptions()
                            .frame(1000000)
                            .centerCrop()
                            .error(res)
                            .placeholder(res))
            .load(url)
            .into(mCoverImage);
}
 
Example #30
Source File: TypeTwoContentPresenter.java    From LeanbackTvSample with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    if (item instanceof Content.DataBean.WidgetsBean) {
        ViewHolder vh = (ViewHolder) viewHolder;
        Glide.with(mContext)
                .load(((Content.DataBean.WidgetsBean) item).getUrl())
                .apply(new RequestOptions()
                        .centerCrop()
                        .override(FontDisplayUtil.dip2px(mContext, 272),
                                FontDisplayUtil.dip2px(mContext, 186))
                        .placeholder(R.drawable.bg_shape_default))
                .into(vh.mIvTypeTwoPoster);
    }
}