Java 类com.bumptech.glide.Glide 实例源码

项目:Hitalk    文件:NewFriendConfirmLayout.java   
public void initWith(AddRequest item) {
    AVUser avUser = item.getFromUser();
    if (avUser != null) {
        User user = UserBeanCacheHelper.AvUserToUser(avUser,new User());
        nickTv.setText(user.getNick());

        Glide.with(mAppCtx).load(user.getAvatar()).placeholder(R.drawable.default_avatar).into(iconIv);

        infoTv.setText(mAppCtx.getText(R.string.preIntroduce)+user.getNick());

        int status = item.getStatus();
        if (status == AddRequest.STATUS_WAIT) {
            acceptBtn.setSelected(false);
            acceptBtn.setText(R.string.accept);
        } else if (status == AddRequest.STATUS_DONE) {
            acceptBtn.setSelected(true);
            acceptBtn.setText(R.string.accepted);
        }
    }
}
项目:MobileMedia    文件:SearchAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHoder viewHoder;
    if(convertView ==null){
        convertView = View.inflate(context, R.layout.net_video_item,null);
        viewHoder = new ViewHoder();
        viewHoder.iv_icon = (ImageView) convertView.findViewById(R.id.net_video_img);
        viewHoder.tv_name = (TextView) convertView.findViewById(R.id.net_video_name);
        viewHoder.tv_desc = (TextView) convertView.findViewById(R.id.net_video_desc);

        convertView.setTag(viewHoder);
    }else{
        viewHoder = (ViewHoder) convertView.getTag();
    }
    SearchBean.ItemData mediaItem = mediaItems.get(position);
    viewHoder.tv_name.setText(mediaItem.getItemTitle());
    viewHoder.tv_desc.setText(mediaItem.getKeywords());
    Glide.with(context).load(mediaItem.getItemImage().getImgUrl1())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .placeholder(R.drawable.video_default)
            .error(R.drawable.video_default)
            .into(viewHoder.iv_icon);
    return convertView;
}
项目:Hitalk    文件:MessagePreviewRvAdapter.java   
private void updateAvatar(AVIMConversation conversation,ImageView avatarView) {
    if(null != conversation) {
        if(!conversation.isTransient() && conversation.getMembers().size() <= 2) {
            ConversationUtils.getConversationPeerIcon(conversation, new AVCallback<String>() {
                protected void internalDone0(String s, AVException e) {
                    if(null != e) {
                        NLog.e(TagUtil.makeTag(getClass()),"updateAvatar failed :",e);
                    }
                    if(!TextUtils.isEmpty(s)) {
                        Glide.with(HiTalkApplication.mAppContext).load(s).placeholder(R.drawable.default_avatar).into(avatarView);
                    } else {
                        avatarView.setImageResource(R.drawable.default_avatar);
                    }

                }
            });
        } else {
            avatarView.setImageResource(R.drawable.default_group_icon);
        }
    }
}
项目:BilibiliClient    文件:AllAreasRankAdapter.java   
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    AllareasRankInfo.RankBean.ListBean listBean = allRanks.get(position);
    itemViewHolder.mVideoTitle.setText(listBean.getTitle());
    itemViewHolder.mVideoPlayNum.setText(String.valueOf(listBean.getPlay()));
    itemViewHolder.mVideoReviewCount.setText(String.valueOf(listBean.getVideo_review()));
    itemViewHolder.mUserName.setText(listBean.getAuthor());
    itemViewHolder.mSortNum.setText(String.valueOf(position + 1));
    setSortNumTextSize(itemViewHolder, position);

    Glide.with(getContext())
        .load(listBean.getPic())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.bili_default_image_tv)
        .dontAnimate()
        .into(itemViewHolder.mVideoImg);
  }
  super.onBindViewHolder(holder, position);
}
项目:Daejeon-People    文件:MainPopularAdapter.java   
@Override
public Object instantiateItem(ViewGroup container, int position) {
    // TODO Auto-generated method stub
    View view = null;
    view= inflater.inflate(R.layout.main_viewpager_popular, null);
    ImageView img= (ImageView)view.findViewById(R.id.img_viewpager_childimage);
    TextView maintext = (TextView)view.findViewById(R.id.text_viewpager_main);
    TextView subtext = (TextView)view.findViewById(R.id.text_viewpager_sub);
    Log.d("position", position+"");
    maintext.setText(mDataset.get(position).getTitle());
    subtext.setText(mDataset.get(position).getEng_title());
    Log.d("image url", mDataset.get(position).getImage());

    if(mDataset.get(position).getImage() == "NoImage"){
        Glide.with(mContext).load(R.drawable.noimage).into(img);
    } else {
        String imgUrl = mDataset.get(position).getImage().substring(1, mDataset.get(position).getImage().length() - 1);
        Log.d("image url2", imgUrl);
        Glide.with(mContext).load(imgUrl).into(img);
    }
    container.addView(view);
    return view;
}
项目:cleaninsights-android-sdk    文件:PlaybackOverlayActivity.java   
private void updateMetadata(final Movie movie) {
    final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();

    String title = movie.getTitle().replace("_", " -");

    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title);
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
            movie.getDescription());
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
            movie.getCardImageUrl());

    // And at minimum the title and artist for legacy support
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title);
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, movie.getStudio());

    Glide.with(this)
            .load(Uri.parse(movie.getCardImageUrl()))
            .asBitmap()
            .into(new SimpleTarget<Bitmap>(500, 500) {
                @Override
                public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                    metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
                    mSession.setMetadata(metadataBuilder.build());
                }
            });
}
项目:BilibiliClient    文件:AllAreasRankAdapter.java   
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    AllareasRankInfo.RankBean.ListBean listBean = allRanks.get(position);
    itemViewHolder.mVideoTitle.setText(listBean.getTitle());
    itemViewHolder.mVideoPlayNum.setText(String.valueOf(listBean.getPlay()));
    itemViewHolder.mVideoReviewCount.setText(String.valueOf(listBean.getVideo_review()));
    itemViewHolder.mUserName.setText(listBean.getAuthor());
    itemViewHolder.mSortNum.setText(String.valueOf(position + 1));
    setSortNumTextSize(itemViewHolder, position);

    Glide.with(getContext())
        .load(listBean.getPic())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.bili_default_image_tv)
        .dontAnimate()
        .into(itemViewHolder.mVideoImg);
  }
  super.onBindViewHolder(holder, position);
}
项目:TootApp    文件:StatusesListAdapter.java   
private void setImageOrSensitive(String url, ImageView imageView, boolean sensitiveContent) {
    if (!sensitiveContent) {
        Glide
                .with(parentCtx)
                .load(url)
                .crossFade()
                .into(imageView);
    } else {
        imageView.setImageDrawable(new ColorDrawable(Color.GRAY));
    }
    imageView.setVisibility(View.VISIBLE);
}
项目:Cable-Android    文件:MediaUtil.java   
private static Bitmap generateImageThumbnail(Context context, MasterSecret masterSecret, Uri uri)
    throws BitmapDecodingException
{
  try {
    int maxSize = context.getResources().getDimensionPixelSize(R.dimen.media_bubble_height);
    return Glide.with(context)
                .load(new DecryptableUri(masterSecret, uri))
                .asBitmap()
                .centerCrop()
                .into(maxSize, maxSize)
                .get();
  } catch (InterruptedException | ExecutionException e) {
    Log.w(TAG, e);
    throw new BitmapDecodingException(e);
  }
}
项目:BilibiliClient    文件:BangumiDetailsRecommendAdapter.java   
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    BangumiDetailsRecommendInfo.ResultBean.ListBean listBean = bangumiRecommends.get(position);

    Glide.with(getContext())
        .load(listBean.getCover())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.bili_default_image_tv)
        .dontAnimate()
        .into(itemViewHolder.mImage);

    itemViewHolder.mTitle.setText(listBean.getTitle());
    itemViewHolder.mFollow.setText(
        NumberUtil.converString(Integer.valueOf(listBean.getFollow())) + "人追番");
  }
  super.onBindViewHolder(holder, position);
}
项目:GitHub    文件:ProductDetailsActivity.java   
private void renderData(ProductDetailsViewState.DataState state) {
  TransitionManager.beginDelayedTransition(rootView);
  errorView.setVisibility(View.GONE);
  loadingView.setVisibility(View.GONE);
  detailsView.setVisibility(View.VISIBLE);

  isProductInshoppingCart = state.getDetail().isInShoppingCart();
  product = state.getDetail().getProduct();
  price.setText("Price: $" + String.format(Locale.US, "%.2f", product.getPrice()));
  description.setText(product.getDescription());
  toolbar.setTitle(product.getName());
  collapsingToolbarLayout.setTitle(product.getName());

  if (isProductInshoppingCart) {
    fab.setImageResource(R.drawable.ic_in_shopping_cart);
  } else {
    fab.setImageResource(R.drawable.ic_add_shopping_cart);
  }

  Glide.with(this)
      .load(DependencyInjection.BASE_IMAGE_URL + product.getImage())
      .centerCrop()
      .into(backdrop);
}
项目:ScrollShapeUI    文件:NeteasePlaylistActivity.java   
/**
 * 高斯背景图和一般图片
 */
private void setPicture() {
    Glide.with(this)
            .load(IMAGE_URL_LARGE)
            .override((int) CommonUtils.getDimens(R.dimen.movie_detail_width), (int) CommonUtils.getDimens(R.dimen.movie_detail_height))
            .into(binding.include.ivOnePhoto);

    // "14":模糊度;"3":图片缩放3倍后再进行模糊
    Glide.with(this)
            .load(IMAGE_URL_MEDIUM)
            .error(R.drawable.stackblur_default)
            .placeholder(R.drawable.stackblur_default)
            .crossFade(500)
            .bitmapTransform(new BlurTransformation(this, 14, 3))
            .into(binding.include.imgItemBg);
}
项目:UdacityBakingAndroid    文件:StepAdapter.java   
@Override
public void onBindViewHolder(StepHolder holder, int position) {
    holder.mStep = mStepList.get(position);
    holder.mBinding.cvStepItemHolder.setSelected(mSelectedPosition == position);

    if(holder.mStep.getVideoURL()!=null && !holder.mStep.getVideoURL().matches("")) {
        Glide.with(holder.itemView.getContext())
                .load(holder.mStep.getThumbnailURL())
                .placeholder(R.drawable.ic_videocam_black_24dp)
                .error(R.drawable.ic_videocam_black_24dp)
                .dontAnimate()
                .into(holder.mBinding.ivStepItemVideoThumb);
    } else {
        holder.mBinding.ivStepItemVideoThumb.setImageResource(R.drawable.ic_videocam_off_black_24dp);
    }
    if(holder.mStep.getId() == 0)
        holder.mBinding.tvStepListStepNumber.setText("   ");
    else
    holder.mBinding.tvStepListStepNumber.setText(String.valueOf(holder.mStep.getId()) + ": ");
    holder.mBinding.tvStepListStepShortDesc.setText(holder.mStep.getShortDescription());
}
项目:popomusic    文件:PicAdapter.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    Contentlist contentlist= list.get(position);
    // 随机高度, 模拟瀑布效果.
    if (mHeights.size() <= position) {
        mHeights.add((int) (100 + Math.random() * 300));
    }
    ViewGroup.LayoutParams lp = ((ViewHolder) holder).imageView.getLayoutParams();
    lp.height = mHeights.get(position);
    ((ViewHolder) holder).imageView.setLayoutParams(lp);
    Glide.with(UIcollector.getContext())
            .load(contentlist.getList().get(0).getMiddle())
            .override(300, 400)
            .into(((ViewHolder) holder).imageView);
    ((ViewHolder) holder).imageView.setOnClickListener(view -> {
        if (null != onItemClickListener) {
            onItemClickListener.onItemClickListener(((ViewHolder) holder).imageView, position);
        }
    });
}
项目:Croprotector    文件:DiseaseInfoAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder,int position){
    //得到当前项DiseaseInfo实例
    DiseaseInfo disease= myDiseaseInfoList.get(position);
    //得到时间
    holder.time.setText(disease.getInfoTime());
    //得到疾病名称
    holder.name.setText(disease.getDiseaseKind().getDiseaseName());
    //得到疾病位置,精确到个位
    int longitude=(int)disease.getLongitude();
    int latitude=(int)disease.getLatitude();
    String longitudeStr=String.valueOf(longitude);
    String latitudeStr=String.valueOf(latitude);
    holder.location.setText("("+longitudeStr+","+latitudeStr+")");
    //得到疾病图片
    Bitmap bm=PictureClass.StringToBitmap(disease.getPicture());
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG,100,baos);
    byte[] buff=baos.toByteArray();
    Glide.with(mContext).load(buff).into(holder.disease_pic);
}
项目:BilibiliClient    文件:ActivityCenterAdapter.java   
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    ActivityCenterInfo.ListBean listBean = activityCenters.get(position);

    Glide.with(getContext())
        .load(listBean.getCover())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.bili_default_image_tv)
        .dontAnimate()
        .into(itemViewHolder.mImage);

    itemViewHolder.mTitle.setText(listBean.getTitle());

    if (listBean.getState() == 1) {
      itemViewHolder.mState.setImageResource(R.drawable.ic_badge_end);
    } else {
      itemViewHolder.mState.setImageResource(R.drawable.ic_badge_going);
    }
  }
  super.onBindViewHolder(holder, position);
}
项目:InstaFlickr    文件:CommentsAdapter.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    CommentViewHolder viewHolder = (CommentViewHolder) holder;
    if(position<10){
        switch(position%3){
            case 0:
                viewHolder.tvComment.setText("comment1");
                break;
            case 1:
                viewHolder.tvComment.setText("comment2");
                break;
            case 2:
                viewHolder.tvComment.setText("comment3");
                break;
        }
    }else{
        viewHolder.tvComment.setText(mCommentString);//更新评论字符串
    }

    Glide.with(mContext)
            .load(R.drawable.ic_launcher)
            .centerCrop()
            .into(viewHolder.ivUserAvatar);
}
项目:SuperNote    文件:EditNotePresenter.java   
private void displayImage() {

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;  // 对图片进行设置 但不形成示例,不耗费内存

        BitmapFactory.decodeFile(mImageFile.getPath(), options);

        int imageRequestWidth = getRequestImeWidth();
        int imageRequestHeight = getRequestImeHeight(options);
        Logger.d("width " + imageRequestWidth + "   height:" + imageRequestHeight);
        Logger.d("bitmap1 width " + options.outWidth + "   height:" + options.outHeight);

        Glide.with(mView.getActivity())
                .load(mImageFile)
                .asBitmap()
                .override(imageRequestWidth, imageRequestHeight)  // 设置大小
                .fitCenter()                                     // 不按照比例
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        //根据Bitmap对象创建ImageSpan对象
                        Logger.d("bitmap width:" + resource.getWidth() + "   height:" + resource.getHeight());
                        mView.insertImage(mImageName, resource);
                    }
                });
    }
项目:BilibiliClient    文件:HomeBangumiNewSerialSection.java   
@Override
public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    BangumiAppIndexInfo.ResultBean.SerializingBean serializingBean = mSerials.get(position);
    Glide.with(mContext)
            .load(serializingBean.getCover())
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .placeholder(R.drawable.bili_default_image_tv)
            .dontAnimate()
            .into(itemViewHolder.mImage);
    itemViewHolder.mTitle.setText(serializingBean.getTitle());
    itemViewHolder.mPlay.setText(NumberUtil.converString(serializingBean.getWatching_count()) + "人在看");
    itemViewHolder.mUpdate.setText("更新至第" + serializingBean.getNewest_ep_index() + "话");
    itemViewHolder.mCardView.setOnClickListener(v -> BangumiDetailsActivity.launch((Activity) mContext, serializingBean.getSeason_id()));
}
项目:FakeWeather    文件:HourlyAdapter.java   
@Override
protected void convert(final BaseViewHolder helper, FakeWeather.FakeForecastHourly item) {
    int width = SizeUtils.getScreenWidth(mContext) / 5;
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) helper.itemView.getLayoutParams();
    params.width = width;
    helper.itemView.setLayoutParams(params);
    helper.setText(R.id.tv_hourly_temp, item.getTemp() + "°");
    helper.setText(R.id.tv_hourly_time, item.getTime());
    final ImageView imageView = helper.getView(R.id.iv_hourly_weather);
    WeatherUtil.getInstance().getWeatherDict(item.getCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() {
        @Override
        public void onNext(WeatherBean weatherBean) {
            Glide.with(mContext).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
        }
    });
}
项目:BilibiliClient    文件:RegionDetailsNewsVideoSection.java   
@Override
public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {

  ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
  RegionDetailsInfo.DataBean.NewBean newBean = newsVideos.get(position);

  Glide.with(mContext)
      .load(newBean.getCover())
      .centerCrop()
      .diskCacheStrategy(DiskCacheStrategy.ALL)
      .placeholder(R.drawable.bili_default_image_tv)
      .dontAnimate()
      .into(itemViewHolder.mVideoPic);
  itemViewHolder.mTitle.setText(newBean.getTitle());
  itemViewHolder.mUpName.setText(newBean.getName());
  itemViewHolder.mPlay.setText(String.valueOf(newBean.getPlay()));
  itemViewHolder.mReview.setText(String.valueOf(newBean.getDanmaku()));
  itemViewHolder.mItemView.setOnClickListener(
      v -> VideoDetailsActivity.launch((Activity) mContext,
          Integer.valueOf(newBean.getParam()), newBean.getCover()));
}
项目:MaterialLearning    文件:HoroAdapter.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    if(holder instanceof  ViewHolder){
        Horoscope horoscope = mHoroList.get(position);
        ViewHolder horoVH=(ViewHolder)holder;
        horoVH.enName.setText(horoscope.geteNname());
        horoVH.cnName.setText(horoscope.getcNname());
        Glide.with(mContext).load(horoscope.getImageId()).into(horoVH.horoImage);
    }else if(holder instanceof  AlbumViewHolder){
        AlbumViewHolder AlbumVH=(AlbumViewHolder)holder;
        LinearLayoutManager manager=new LinearLayoutManager(mContext);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        AlbumVH.horizon.setLayoutManager(manager);
        AlbumAdapter albumAdapter= new AlbumAdapter(albumList);
        AlbumVH.horizon.setAdapter(albumAdapter);
    }



}
项目:Matisse-Image-and-Video-Selector    文件:GlideEngine.java   
@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
    Glide.with(context)
            .load(uri)
            .asBitmap()  // some .jpeg files are actually gif
            .placeholder(placeholder)
            .override(resize, resize)
            .centerCrop()
            .into(imageView);
}
项目:FastAndroid    文件:RecyclerViewPreloader.java   
/**
 * Helper constructor that accepts an {@link android.support.v4.app.Fragment}.
 */
public RecyclerViewPreloader(Fragment fragment,
                             PreloadModelProvider<T> preloadModelProvider,
                             PreloadSizeProvider<T> preloadDimensionProvider,
                             int maxPreload) {

    this(Glide.with(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload);
}
项目:GitHub    文件:BindingUtils.java   
@BindingAdapter({"roundImageUrl"})
public static void loadRoundImg(ImageView v, String url) {
    v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY);
    Glide.with(v.getContext())
            .load(getFuckUrl(url))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .transform(new GlideCircleTransform(v.getContext()))
            .error(R.mipmap.ic_launcher)
            .into(v);
}
项目:CompositionAvatar    文件:BindingUtil.java   
/**
 * 异步加载图片
 *
 * @param view   the view
 * @param resIds 图片资源ID
 */
static void asyncLoadDrawable(CompositionAvatarView view, int... resIds) {
    int length = Math.min(resIds.length, CompositionAvatarView.MAX_DRAWABLE_COUNT);
    for (int i = 0; i < length; i++) {
        // 图片布局的顺序是按添加的顺序以顺时针方向布局的,所以可以添加点位图以固定图片的显示顺序
        view.addDrawable(DRAWABLE_IDS[i], new ColorDrawable(0xffdddddd));
        Glide.with(view.getContext())
                .fromResource()
                .load(resIds[i])
                // .placeholder(new ColorDrawable(0xffdddddd)) // 由于异步,这里并不能保证显示的顺序
                .into(new CompositionAvatarViewTarget(view, DRAWABLE_IDS[i]));
    }
}
项目:GitHub    文件:BannerPracticeActivity.java   
@Override
protected void convert(BaseViewHolder viewHolder, Movie item) {
    viewHolder.setText(R.id.lmi_title, item.filmName)
            .setText(R.id.lmi_actor, item.actors)
            .setText(R.id.lmi_grade, item.grade)
            .setText(R.id.lmi_describe, item.shortinfo);
    Glide.with(mContext).load(item.picaddr).into((ImageView) viewHolder.getView(R.id.lmi_avatar));
}
项目:PeSanKita-android    文件:TextSecureGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
  glide.register(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory());
  glide.register(ContactPhotoUri.class, InputStream.class, new ContactPhotoUriLoader.Factory());
  glide.register(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
  glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
项目:mvvm-template    文件:DrawableGetter.java   
@Override public Drawable getDrawable(@NonNull String url) {
    final UrlDrawable urlDrawable = new UrlDrawable();
    if (container != null && container.get() != null) {
        Context context = container.get().getContext();
        final GenericRequestBuilder load = Glide.with(context)
                .load(url)
                .dontAnimate();
        final GlideDrawableTarget target = new GlideDrawableTarget(urlDrawable, container, width);
        load.into(target);
        cachedTargets.add(target);
    }
    return urlDrawable;
}
项目:FanChat    文件:EaseUserUtils.java   
/**
 * set user avatar
 * @param username
 */
public static void setUserAvatar(Context context, String username, ImageView imageView){
    EaseUser user = getUserInfo(username);
    if(user != null && user.getAvatar() != null){
        try {
            int avatarResId = Integer.parseInt(user.getAvatar());
            Glide.with(context).load(avatarResId).into(imageView);
        } catch (Exception e) {
            //use default avatar
            Glide.with(context).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ease_default_avatar).into(imageView);
        }
    }else{
        Glide.with(context).load(R.drawable.ease_default_avatar).into(imageView);
    }
}
项目:RLibrary    文件:RApplication.java   
@Override
    public void onLowMemory() {
        if (BuildConfig.DEBUG) {
            T_.show("请注意, 内存过低!");
        }
        Glide.get(this).clearMemory();
        //Fresco.shutDown();
//        if (Fresco.hasBeenInitialized()) {
//            Fresco.getImagePipeline().clearMemoryCaches();
//        }
        super.onLowMemory();
    }
项目:androidtv-sample    文件:VideoDetailsFragment.java   
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo);

    Glide.with(this)
            .load(mSelectedVideo.cardImageUrl)
            .asBitmap()
            .dontAnimate()
            .error(R.drawable.default_background)
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(final Bitmap resource,
                        GlideAnimation glideAnimation) {
                    row.setImageBitmap(getActivity(), resource);
                    startEntranceTransition();
                }
            });

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources()
            .getString(R.string.watch_trailer_1),
            getResources().getString(R.string.watch_trailer_2)));
    adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
}
项目:BaseCore    文件:ImageViewBindingAdapter.java   
@BindingAdapter(value = {"imageUrl", "placeHolder", "error"}, requireAll = false)
/**
 * 不支持mipmap下的图片
 */
public static void loadImage(ImageView imageView, String url, Drawable holderDrawable, Drawable errorDrawable) {

    Glide.with(imageView.getContext())
            .load(url)
            .apply(GlideRequestOption.getRequestOptions().placeholder(holderDrawable)
                    .error(errorDrawable))
            .into(imageView);
}
项目:BilibiliClient    文件:AttentionDynamicAdapter.java   
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    AttentionDynamicInfo.DataBean.FeedsBean feedsBean = dynamics.get(position);

    Glide.with(getContext())
        .load(feedsBean.getAddition().getPic())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.bili_default_image_tv)
        .dontAnimate()
        .into(itemViewHolder.mImage);

    Glide.with(getContext())
        .load(feedsBean.getSource().getAvatar())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.ico_user_default)
        .dontAnimate()
        .into(itemViewHolder.mAvatar);

    itemViewHolder.mName.setText(feedsBean.getSource().getUname());
    itemViewHolder.mTitle.setText(feedsBean.getAddition().getTitle());
    itemViewHolder.mPlay.setText(NumberUtil.converString(feedsBean.getAddition().getPlay()));
    itemViewHolder.mReview.setText(
        NumberUtil.converString(feedsBean.getAddition().getVideo_review()));
    itemViewHolder.mUpdateTime.setText(
        WeekDayUtil.formatDate(feedsBean.getAddition().getCreate()));
  }
  super.onBindViewHolder(holder, position);
}
项目:L-Assistant    文件:DetailsFragment.java   
private void setCover(@Nullable String url) {
    if (url != null) {
        Glide.with(getContext())
                .load(url)
                .asBitmap()
                .placeholder(R.drawable.placeholder)
                .centerCrop()
                .error(R.drawable.placeholder)
                .into(mImageView);
    } else {
        mImageView.setImageResource(R.drawable.placeholder);
    }
}
项目:EasyEmoji    文件:ImageLoader.java   
/**
 * 重载方法 加载展示圆形图片
 * @param round 调用方传布尔值即视为要加载圆形图片
 */
public void displayImage(Context context, String uri, ImageView view , int defaultIcon, boolean round) {
    Glide.with(context)
            .load(uri)
            .diskCacheStrategy(mDiskCacheStrategy)
            .transform(new GlideCircleTransform(context))
            .placeholder(defaultIcon)
            .error(defaultIcon)
            .into(view);
}
项目:GitHub    文件:TopRankAdapter.java   
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    final View group = inflater.inflate(R.layout.item_top_rank_group, null);

    ImageView ivCover = (ImageView) group.findViewById(R.id.ivRankCover);
    if (!TextUtils.isEmpty(groupArray.get(groupPosition).cover)) {
        Glide.with(mContext).load(Constant.IMG_BASE_URL + groupArray.get(groupPosition).cover).placeholder(R.drawable.avatar_default)
                .transform(new GlideCircleTransform(mContext)).into(ivCover);
        group.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onItemClick(group, groupPosition, groupArray.get(groupPosition));
                }
            }
        });
    } else {
        ivCover.setImageResource(R.drawable.ic_rank_collapse);
    }

    TextView tvName = (TextView) group.findViewById(R.id.tvRankGroupName);
    tvName.setText(groupArray.get(groupPosition).title);

    ImageView ivArrow = (ImageView) group.findViewById(R.id.ivRankArrow);
    if (childArray.get(groupPosition).size() > 0) {
        if (isExpanded) {
            ivArrow.setImageResource(R.drawable.rank_arrow_up);
        } else {
            ivArrow.setImageResource(R.drawable.rank_arrow_down);
        }
    } else {
        ivArrow.setVisibility(View.GONE);
    }
    return group;
}
项目:referendum_1o_android    文件:ImageActivity.java   
@Override
protected File doInBackground(String... params) {
    String url = params[0];
    try {
        return Glide
                .with(context)
                .downloadOnly()
                .load(url)
                .submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                .get();
    } catch (Exception ex) {
        return null;
    }
}
项目:TripBuyer    文件:ImageUtil.java   
public static void requestImgFromBytes(Context context, byte[] bytes, ImageView view) {
    Glide.with(context)
            .load(bytes)
            .placeholder(R.color.grey_300)
            .error(R.color.red_300)
            .into(view);
}
项目:anitrend-app    文件:SeriesCharacterAdapter.java   
@Override
public void onBindViewHolder(CharacterSmall model) {

    Glide.with(mContext).load(model.getImage_url_lge())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(model_image);

    name.setText(String.format(Locale.getDefault(), "%s %s", model.getName_first(), model.getName_last()));
    if(model.getRole() != null)
        role.setText(model.getRole());
}