Java Code Examples for com.bumptech.glide.load.engine.DiskCacheStrategy

The following examples show how to use com.bumptech.glide.load.engine.DiskCacheStrategy. These examples are extracted from open source projects. 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 Project: ZhihuDaily   Source File: CommentItemDelegate.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void convert(ViewHolder holder, BaseItem baseItem, int position) {
    Context context = holder.getConvertView().getContext();
    StoryContentComment comment = (StoryContentComment) baseItem;
    if ((boolean) SharedPreferencesUtils.get(App.getContext(), "NO_IMAGE_MODE", false)
            && !NetWorkUtils.isWifiConnected(App.getContext())) {
        Glide.with(context)
                .load(R.drawable.account_avatar)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .transform(new CircleTransform(context))
                .into((ImageView) holder.getView(R.id.avatar));
    } else {
        Glide.with(context)
                .load(comment.getAvatar())
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .transform(new CircleTransform(context))
                .into((ImageView) holder.getView(R.id.avatar));
    }
    holder.setText(R.id.author, comment.getAuthor());
    holder.setText(R.id.content, comment.getContent());
    holder.setText(R.id.likes, Integer.toString(comment.getLikes()));
    holder.setText(R.id.time, comment.getTime());
}
 
Example 2
Source Project: GankDaily   Source File: ViewListAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder,final int position) {
    Girl entity = mListData.get(position);

    Glide.with(mContext)
            .load(entity.url)
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate()
            .into(holder.mIvIndexPhoto)
            .getSize(new SizeReadyCallback() {
                @Override
                public void onSizeReady(int width, int height) {
                    //holder.mIvIndexPhoto.setColorFilter(mColorFilter);
                }
            });
    holder.mTvTime.setText(DateUtil.toDate(entity.publishedAt));
    if(mIClickItem!=null){
        holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto,holder.mTvTime);
            }
        });
    }
}
 
Example 3
Source Project: SendBird-Android   Source File: ImageUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Displays an image from a URL in an ImageView.
 */
public static void displayGifImageFromUrl(Context context, String url, ImageView imageView, RequestListener listener) {
    RequestOptions myOptions = new RequestOptions()
            .dontAnimate()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);

    if (listener != null) {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .listener(listener)
                .into(imageView);
    } else {
        Glide.with(context)
                .asGif()
                .load(url)
                .apply(myOptions)
                .into(imageView);
    }
}
 
Example 4
void onBindView() {
    Glide.with(itemView.getContext())
            .load(R.drawable.ic_play_store)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(appStore);
    appStore.setOnClickListener(v ->
            listener.onAppStoreItemClicked("Geometric Weather Icon"));

    Glide.with(itemView.getContext())
            .load(
                    DisplayUtils.isDarkMode(itemView.getContext())
                            ? R.drawable.ic_github_light
                            : R.drawable.ic_github_dark
            ).diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(gitHub);
    gitHub.setOnClickListener(v ->
            listener.onGitHubItemClicked("https://github.com/WangDaYeeeeee/IconProvider-For-GeometricWeather"));

    Glide.with(itemView.getContext())
            .load(R.drawable.ic_chronus)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(chronus);
    chronus.setOnClickListener(v ->
            listener.onAppStoreItemClicked("Chronus Icon"));
}
 
Example 5
@Override
public Object instantiateItem(ViewGroup container, final int position) {
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewPager.LayoutParams.MATCH_PARENT,ViewPager.LayoutParams.MATCH_PARENT);
    ImageView view = new ImageView(activity);
    view.setLayoutParams(params);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    container.addView(view);
    musicInfo nowMusic = musicListNow.get(position);
    if (!nowMusic.getMusicLink().equals("")) {//网络
        Glide.with(activity).load(nowMusic.getMusicLargeAlbum()).centerCrop().diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.default_album).into(view);
    } else {//本地
        if (nowMusic.getAlbumLink() != null) {//本地下载
            Glide.with(activity).load(nowMusic.getAlbumLink()).placeholder(R.drawable.default_album).centerCrop().into(view);
        } else {//本地原有
          Glide.with(activity).load(ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), nowMusic.getMusicAlbumId())).centerCrop().placeholder(R.drawable.default_album).into(view);
        }
    }
    view.setOnClickListener(MyApplication.getlyric_onClickListener());
    return view;
}
 
Example 6
Source Project: LeisureRead   Source File: SectionsAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    SectionsInfo.DataBean dailySectionsInfo = mDataSources.get(position);

    Glide.with(getContext())
        .load(dailySectionsInfo.getThumbnail())
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .placeholder(R.drawable.account_avatar)
        .into(itemViewHolder.mImageView);

    itemViewHolder.mDes.setText(dailySectionsInfo.getDescription());
    itemViewHolder.mName.setText(dailySectionsInfo.getName());
  }
  super.onBindViewHolder(holder, position);
}
 
Example 7
@SuppressWarnings("ConstantConditions")
protected void loadFileImage(File file, final ViewHolder holder) {
    final int iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor);
    if (file.isDirectory()) {
        holder.image.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
        holder.image.setImageResource(R.drawable.ic_folder_white_24dp);
    } else {
        Drawable error = Util.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor);
        Glide.with(activity)
                .load(new AudioFileCover(file.getPath()))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .error(error)
                .placeholder(error)
                .animate(android.R.anim.fade_in)
                .signature(new MediaStoreSignature("", file.lastModified(), 0))
                .into(holder.image);
    }
}
 
Example 8
public void setInitialValue(String value) {

        if (!isEmpty(value)) {

            Glide.with(image).clear(image);
            clearButton.setVisibility(View.VISIBLE);

            File file = new File(value);

            if (file.exists()) {
                currentValue = value;
                setTextSelected(getContext().getString(R.string.image_selected));
                image.setVisibility(View.VISIBLE);
                Glide.with(image)
                        .load(file)
                        .apply(new RequestOptions().centerCrop())
                        .apply(RequestOptions.skipMemoryCacheOf(true))
                        .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
                        .skipMemoryCache(true)
                        .into(image);
            }
        } else
            clearButton.setVisibility(View.GONE);
    }
 
Example 9
Source Project: Silence   Source File: ZoomingImageView.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void setImageViewUri(MasterSecret masterSecret, Uri uri) {
  subsamplingImageView.setVisibility(View.GONE);
  imageView.setVisibility(View.VISIBLE);

  Glide.with(getContext())
       .load(new DecryptableUri(masterSecret, uri))
       .diskCacheStrategy(DiskCacheStrategy.NONE)
       .dontTransform()
       .dontAnimate()
       .into(new GlideDrawableImageViewTarget(imageView) {
         @Override protected void setResource(GlideDrawable resource) {
           super.setResource(resource);
           imageViewAttacher.update();
         }
       });
}
 
Example 10
Source Project: Orin   Source File: SongFileAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
protected void loadFileImage(File file, final ViewHolder holder) {
    final int iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor);
    if (file.isDirectory()) {
        holder.image.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
        holder.image.setImageResource(R.drawable.ic_folder_white_24dp);
    } else {
        Drawable error = Util.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor);
        Glide.with(activity)
                .load(new AudioFileCover(file.getPath()))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .error(error)
                .placeholder(error)
                .animate(android.R.anim.fade_in)
                .signature(new MediaStoreSignature("", file.lastModified(), 0))
                .into(holder.image);
    }
}
 
Example 11
Source Project: glide-support   Source File: TestListFragment.java    License: The Unlicense 6 votes vote down vote up
@Override public View getView(int position, View convertView, ViewGroup parent) {
	ImageView imageView = recycle(convertView, parent);

	//.with(getActivity().getApplicationContext())
	//or
	//Glide.with(this).resumeRequests();
	// AND imageview size must not have match_parent
	SyncLoadImageViewTarget target = Glide
			.with(TestListFragment.this)
			.load(getItem(position))
			.diskCacheStrategy(DiskCacheStrategy.ALL)
			.placeholder(R.drawable.glide_placeholder)
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(new SyncLoadImageViewTarget(imageView));

	Log.d("isLoaded", target.isLoaded() + "");
	if (!target.isLoaded()) {
		//Glide.clear(target); NOT CLEARING ANYMORE
	}

	return imageView;
}
 
Example 12
Source Project: BaseProject   Source File: TinyGifDrawableLoader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 加载不一定是本地图片资源
 * (即也可以是网络资源)
 * 并且也可以不是gif图片
 * @param context
 * @param model
 * @param iv
 * @param playTimes
 */
public void loadMaybeGifDrawable(Context context,Object model,ImageView iv,int playTimes) {
    if (context == null || iv == null) {
        return;
    }
    iv.setVisibility(View.VISIBLE);
    theDisPlayImageView = new WeakReference<>(iv);
    this.playTimes = playTimes;
    RequestBuilder builder = Glide.with(context.getApplicationContext())
            .asGif()
            ;
    if (loadCallback != null || playTimes >=1) {//指定了播放次数,则需要监听动画执行的结束
        builder.listener(this);
    }
    RequestOptions options = new RequestOptions();
    options.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
    builder.apply(options)
            .load(model)
            .into(iv)
    ;
}
 
Example 13
Source Project: GestureViews   Source File: DemoGlideHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static void loadFlickrFull(Photo photo, ImageView image, LoadingListener listener) {
    final String photoUrl = photo.getLargeSize() == null
            ? photo.getMediumUrl() : photo.getLargeUrl();

    final RequestOptions options = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.DATA)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .dontTransform();

    final RequestBuilder<Drawable> thumbRequest = Glide.with(image)
            .load(photo.getMediumUrl())
            .apply(options);

    Glide.with(image)
            .load(photoUrl)
            .apply(new RequestOptions().apply(options).placeholder(image.getDrawable()))
            .thumbnail(thumbRequest)
            .listener(new RequestListenerWrapper<>(listener))
            .into(image);
}
 
Example 14
Source Project: Melophile   Source File: AlbumAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View instantiateItem(ViewGroup container, int position) {
  View view = inflater.inflate(R.layout.adapter_album, container, false);
  ImageView image = ButterKnife.findById(view, R.id.image);

  Glide.with(container.getContext())
          .load(albums.get(position).getArtworkUrl())
          .asBitmap()
          .priority(Priority.IMMEDIATE)
          .diskCacheStrategy(DiskCacheStrategy.RESULT)
          .into(new ImageViewTarget<Bitmap>(image) {
            @Override
            protected void setResource(Bitmap resource) {
              image.setImageBitmap(resource);
              if (position == current && !isLoaded) {
                isLoaded = true;
                if (callback != null) {
                  callback.onTransitionImageLoaded(image, resource);
                }
              }
            }
          });
  container.addView(view);
  return view;
}
 
Example 15
Source Project: Demo_Public   Source File: GankAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final String url = mItems.get(position);
    Log.e("tag","============onBindViewHolder url: "+url);
    Glide.with(mContext)
            .load(url)
            .placeholder(R.mipmap.ic_launcher)
            .diskCacheStrategy(DiskCacheStrategy.RESULT)
            //.bitmapTransform(new CropCircleTransformation(mContext))  //如果想使用变换效果,这个注释可以打开
            .into(holder.image);
    holder.image.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(mContext,PreviewImageActivity.class);
            intent.putExtra("url",url);
            mContext.startActivity(intent);
        }
    });
}
 
Example 16
Source Project: Ticket-Analysis   Source File: UiUtil.java    License: MIT License 6 votes vote down vote up
public static void setImage(ImageView imageView, String imageUrl, int loadingRes, int errorRes) {
    if (imageView == null) return;

    Context context = imageView.getContext();
    if (context instanceof Activity) {
        if (((Activity) context).isFinishing()) {
            return;
        }
    }
    try {
        Glide.with(context).load(imageUrl)
                .placeholder(loadingRes)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .error(errorRes)
                .into(imageView);
    } catch (Exception e) {
    }
}
 
Example 17
Source Project: YCAudioPlayer   Source File: ImageUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 加载带有圆角的矩形图片  用glide处理
 *
 * @param path   路径
 * @param round  圆角半径
 * @param resId  加载失败时的图片
 * @param target 控件
 */
public static void loadImgByPicassoWithRound(final Context activity, String path, final int round, int resId, final ImageView target) {
    if (path != null && path.length() > 0) {
        Glide.with(activity)
                .load(path)
                .asBitmap()
                .placeholder(resId)
                .error(resId)
                //设置缓存
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(new BitmapImageViewTarget(target) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        super.setResource(resource);
                        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), resource);
                        //设置圆角弧度
                        circularBitmapDrawable.setCornerRadius(round);
                        target.setImageDrawable(circularBitmapDrawable);
                    }
                });
    }
}
 
Example 18
Source Project: Aegis   Source File: EntryHolder.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void loadIcon(Fragment fragment) {
    if (_entry.hasIcon()) {
        Glide.with(fragment)
            .asDrawable()
            .load(_entry)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(false)
            .into(_profileDrawable);
    } else {
        TextDrawable drawable = TextDrawableHelper.generate(_entry.getIssuer(), _entry.getName(), _profileDrawable);
        _profileDrawable.setImageDrawable(drawable);
    }
}
 
Example 19
Source Project: android-tutorials-glide   Source File: UsageExampleCacheBasics.java    License: MIT License 5 votes vote down vote up
private void loadImageDiskStrategySource() {
    Glide
            .with(context)
            .load(eatFoodyImages[2])
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(imageViewFile);
}
 
Example 20
@Override
protected void showMessage(QiscusComment qiscusComment) {
    Nirmana.getInstance().get()
            .setDefaultRequestOptions(new RequestOptions()
                    .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                    .error(R.drawable.ic_qiscus_placehalder_map)
                    .placeholder(R.drawable.ic_qiscus_placehalder_map)
                    .dontAnimate())
            .load(qiscusComment.getLocation().getThumbnailUrl())
            .into(mapImageView);
    locationNameView.setText(qiscusComment.getLocation().getName());
    locationAddressView.setText(qiscusComment.getLocation().getAddress());
}
 
Example 21
private <T> void setAvatar(T model, Bitmap bitmap) {
  avatarBmp = bitmap;
  GlideApp.with(this)
          .load(model)
          .circleCrop()
          .skipMemoryCache(true)
          .diskCacheStrategy(DiskCacheStrategy.NONE)
          .into(avatar);
}
 
Example 22
Source Project: AFBaseLibrary   Source File: AFGlideUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadImage(Object obj, ImageView img) {
    DrawableTypeRequest drawableTypeRequest = getDrawableTypeRequest(obj, img);
    if (drawableTypeRequest == null) {
        drawableTypeRequest = getDrawableTypeRequest(sCommonPlaceholder, img);
    }
    if (drawableTypeRequest != null) {
        drawableTypeRequest
                .centerCrop()
                .dontAnimate()
                .error(sCommonPlaceholder)
                .placeholder(sCommonPlaceholder)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .into(img);
    }
}
 
Example 23
Source Project: Orin   Source File: SearchAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
    switch (getItemViewType(position)) {
        case ALBUM:
            final Album album = (Album) dataSet.get(position);
            holder.title.setText(album.getTitle());
            holder.text.setText(album.getArtistName());
            SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
                    .checkIgnoreMediaStore(activity).build()
                    .into(holder.image);
            break;
        case ARTIST:
            final Artist artist = (Artist) dataSet.get(position);
            holder.title.setText(artist.getName());
            holder.text.setText(MusicUtil.getArtistInfoString(activity, artist));
            Glide.with(activity)
                    .load(new ArtistImage(artist.getName(), false))
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .placeholder(R.drawable.default_artist_image)
                    .animate(android.R.anim.fade_in)
                    .priority(Priority.LOW)
                    .signature(ArtistSignatureUtil.getInstance(activity).getArtistSignature(artist.getName()))
                    .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                    .into(holder.image);
            break;
        case SONG:
            final Song song = (Song) dataSet.get(position);
            holder.title.setText(song.title);
            holder.text.setText(song.albumName);
            break;
        default:
            holder.title.setText(dataSet.get(position).toString());
            break;
    }
}
 
Example 24
@Override public void loadData() {

    ViewCompat.setTransitionName(mImageView, ConstantUtil.TRANSIT_PIC);

    Glide.with(this)
        .load(url)
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(mImageView);

    mImageView.setOnClickListener(v -> {

      //隐藏ToolBar
      hideOrShowToolbar();
    });

    mImageView.setOnLongClickListener(v -> {

      new AlertDialog.Builder(BigImageActivity.this)
          .setMessage("是否保存到本地?")
          .setNegativeButton("取消", (dialog, which) -> dialog.cancel())
          .setPositiveButton("确定", (dialog, which) -> {

            saveImageToGallery();
            dialog.dismiss();
          })
          .show();

      return true;
    });
  }
 
Example 25
Source Project: android-tutorials-glide   Source File: UsageExampleThumbnails.java    License: MIT License 5 votes vote down vote up
private void loadImageThumbnailRequest() {
    DrawableRequestBuilder<String> thumbnailRequest = Glide
            .with(context)
            .load(eatFoodyImages[2])
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE);

    Glide
            .with(context)
            .load(UsageExampleGifAndVideos.gifUrl)
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .thumbnail(thumbnailRequest)
            .into(imageView3);
}
 
Example 26
Source Project: AndroidModulePattern   Source File: GirlsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setData(Girls data) {
    super.setData(data);
    Glide.with(getContext())
            .load(data.getUrl())
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(image);
}
 
Example 27
Source Project: Social   Source File: ModifyUserDataActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void handleModifyHead(Message msg){
     String  result = msg.obj.toString();
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    ModifyHeadRoot root = gson.fromJson(result, ModifyHeadRoot.class);

    if (root == null){
        //new Dialog(this,"错误","链接服务器失败").show();
        Toast.makeText(this,"服务器繁忙,请重试",Toast.LENGTH_LONG).show();
        return;
    }

    if (!root.seccess){
        if(root.message.equals("未登录")){
            OkhttpUtil.autoLogin(handler);
            return;
        }
        new Dialog(this,"提示",root.message).show();
        return ;
    }else{
        Toast.makeText(this,"修改头像成功.",Toast.LENGTH_LONG).show();

        Intent intent = new Intent("com.allever.modifyUserHead");
        intent.putExtra("head_path", WebUtil.HTTP_ADDRESS + root.head_path);
        sendBroadcast(intent);

        //发广播通知MainActivity修改界面
        Intent intent1 = new Intent("com.allever.autologin");
        sendBroadcast(intent);

        Glide.with(this)
                .load(WebUtil.HTTP_ADDRESS + SharedPreferenceUtil.getHeadpath())
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(iv_head);
    }
}
 
Example 28
Source Project: Orin   Source File: AlbumTagEditorActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    PhonographColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = getResizedAlbumCover(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example 29
void bind(@NonNull MediaFolder folder, @NonNull GlideRequests glideRequests, @NonNull EventListener eventListener) {
  title.setText(folder.getTitle());
  count.setText(String.valueOf(folder.getItemCount()));
  icon.setImageResource(folder.getFolderType() == MediaFolder.FolderType.CAMERA ? R.drawable.ic_camera_solid_white_24 : R.drawable.ic_folder_white_48dp);

  glideRequests.load(folder.getThumbnailUri())
               .diskCacheStrategy(DiskCacheStrategy.NONE)
               .transition(DrawableTransitionOptions.withCrossFade())
               .into(thumbnail);

  itemView.setOnClickListener(v -> eventListener.onFolderClicked(folder));
}
 
Example 30
public void setAvatar(@NonNull GlideRequests requestManager, @Nullable Recipient recipient, boolean quickContactEnabled) {
  if (recipient != null) {
    RecipientContactPhoto photo = new RecipientContactPhoto(recipient);

    if (!photo.equals(recipientContactPhoto)) {
      requestManager.clear(this);
      recipientContactPhoto = photo;

      Drawable fallbackContactPhotoDrawable = size == SIZE_SMALL
          ? photo.recipient.getSmallFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider)
          : photo.recipient.getFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider);

      if (photo.contactPhoto != null) {
        requestManager.load(photo.contactPhoto)
                      .fallback(fallbackContactPhotoDrawable)
                      .error(fallbackContactPhotoDrawable)
                      .diskCacheStrategy(DiskCacheStrategy.ALL)
                      .circleCrop()
                      .into(this);
      } else {
        setImageDrawable(fallbackContactPhotoDrawable);
      }
    }

    setAvatarClickHandler(recipient, quickContactEnabled);
  } else {
    recipientContactPhoto = null;
    requestManager.clear(this);
    if (fallbackPhotoProvider != null) {
      setImageDrawable(fallbackPhotoProvider.getPhotoForRecipientWithoutName()
                                            .asDrawable(getContext(), MaterialColor.STEEL.toAvatarColor(getContext()), inverted));
    } else {
      setImageDrawable(unknownRecipientDrawable);
    }

    super.setOnClickListener(listener);
  }
}