com.bumptech.glide.signature.ObjectKey Java Examples

The following examples show how to use com.bumptech.glide.signature.ObjectKey. 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: GlideHelper.java    From hipda with GNU General Public License v2.0 6 votes vote down vote up
public static void loadAvatar(RequestManager glide, ImageView view, String avatarUrl) {
    avatarUrl = Utils.nullToText(avatarUrl);
    String cacheKey = AVATAR_CACHE_KEYS.get(avatarUrl);
    if (cacheKey == null) {
        cacheKey = avatarUrl;
    }
    if (HiSettingsHelper.getInstance().isCircleAvatar()) {
        glide.load(new AvatarModel(avatarUrl))
                .signature(new ObjectKey(cacheKey))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .circleCrop()
                .error(DEFAULT_USER_ICON)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(view);
    } else {
        glide.load(new AvatarModel(avatarUrl))
                .signature(new ObjectKey(cacheKey))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .transform(new CenterCrop(), new RoundedCorners(Utils.dpToPx(4)))
                .error(DEFAULT_USER_ICON)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(view);
    }
}
 
Example #2
Source File: MainActivity.java    From ToDoList with Apache License 2.0 6 votes vote down vote up
/**
 * Glide图片加载
 */
private void glideLoad(){

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

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

    Glide.with(getApplicationContext())
            .load(SPUtils.get(MainActivity.this, "path" ,""))
            .apply(options1)
            .into(user_image);

    Glide.with(getApplicationContext())
            .load(SPUtils.get(MainActivity.this, "path" ,""))
            .apply(bitmapTransform(new BlurTransformation(25, 3)))
            .apply(options2)
            .into(nav_bg);
}
 
Example #3
Source File: TokenHolder.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
private void displayTokenIcon()
{
    String correctedAddr = Keys.toChecksumAddress(token.getAddress());
    String tURL = assetDefinition.getTokenImageUrl(token.tokenInfo.chainId, token.getAddress());
    if (TextUtils.isEmpty(tURL))
    {
        tURL = TRUST_ICON_REPO.replace(ICON_REPO_ADDRESS_TOKEN, correctedAddr);
    }

    int fallbackIcon = EthereumNetworkRepository.getChainLogo(token.tokenInfo.chainId);

    Glide.with(getContext().getApplicationContext())
            .load(tURL)
            .signature(new ObjectKey(correctedAddr + "-" + token.tokenInfo.chainId))
            .apply(new RequestOptions().circleCrop())
            .apply(new RequestOptions().placeholder(fallbackIcon))
            .into(icon);

    icon.setVisibility(View.VISIBLE);
}
 
Example #4
Source File: PictureUtils.java    From science-journal with Apache License 2.0 6 votes vote down vote up
public static void loadExperimentOverviewImage(
    AppAccount appAccount, ImageView imageView, String experimentOverviewFilePath) {
  imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
  String fullPath =
      PictureUtils.getExperimentOverviewFullImagePath(appAccount, experimentOverviewFilePath);
  File file = new File(fullPath);
  Context context = imageView.getContext();
  GlideApp.with(context)
      .load(fullPath)
      .placeholder(R.drawable.experiment_card_placeholder)
      // Create a signature based on the last modified time so that cached images will
      // not be used if the underlying file changes. This may happen if the user has
      // picked an experiment photo from the "edit experiment" page because there is only
      // one filename used for that photo.
      .signature(new ObjectKey(file.getPath() + file.lastModified()))
      .into(imageView);
}
 
Example #5
Source File: ClockRecyclerViewAdapter.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ClockRecyclerViewAdapter.ViewHolder ViewHolder, int i) {

    RequestOptions options2 =new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .skipMemoryCache(true)
            .signature(new ObjectKey(SPUtils.get(context,"head_signature","")))
            .placeholder(R.drawable.ic_img1);

    ViewHolder.clock_title.setText(tomatoList.get(tomatoList.size()-1-i).getTitle());
    ViewHolder.work_time.setText(tomatoList.get(tomatoList.size()-1-i).getWorkLength() + " 分钟");
    ViewHolder.clock_card_bg.setImageBitmap(BitmapUtils.readBitMap(context,tomatoList.get(tomatoList.size()-1-i).getImgId()));

}
 
Example #6
Source File: TodoRecyclerViewAdapter.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(TodoRecyclerViewAdapter.ViewHolder ViewHolder, int i) {

    RequestOptions options2 =new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .skipMemoryCache(true)
            .signature(new ObjectKey(SPUtils.get(context,"head_signature","")))
            .placeholder(R.drawable.ic_img1);

    ViewHolder.todo_title.setText(todosList.get(todosList.size()-1-i).getTitle());
    ViewHolder.todo_desc.setText(todosList.get(todosList.size()-1-i).getDesc());
    ViewHolder.todo_date.setText(todosList.get(todosList.size()-1-i).getDate() + " "+ todosList.get(todosList.size()-1-i).getTime());
    ViewHolder.card_background.setImageBitmap(BitmapUtils.readBitMap(context, todosList.get(todosList.size()-1-i).getImgId()));


    if (todosList.get(todosList.size()-1-i).getIsRepeat() == 1){
        ViewHolder.isRepeat.setText("重复");
        ViewHolder.isRepeat.setTextSize(TypedValue.COMPLEX_UNIT_SP,10);
    }else {
        ViewHolder.isRepeat.setText("单次");
        ViewHolder.isRepeat.setTextSize(TypedValue.COMPLEX_UNIT_SP,10);
    }

    if(todosList.get(todosList.size()-1-i).getRemindTime() <= System.currentTimeMillis() ){
        ViewHolder.timelineView.setMarker(context.getResources().getDrawable(R.drawable.ic_marker));
    }else {
        ViewHolder.timelineView.setMarker(context.getResources().getDrawable(R.drawable.round));
    }


}
 
Example #7
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 #8
Source File: BlurHashModelLoader.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public LoadData<BlurHash> buildLoadData(@NonNull BlurHash blurHash,
                                        int width,
                                        int height,
                                        @NonNull Options options)
{
  return new LoadData<>(new ObjectKey(blurHash.getHash()), new BlurDataFetcher(blurHash));
}
 
Example #9
Source File: PictureUtils.java    From science-journal with Apache License 2.0 5 votes vote down vote up
public static void loadExperimentImage(
    Context context,
    ImageView view,
    AppAccount appAccount,
    String experimentId,
    String relativeFilePath,
    boolean scale) {
  if (isDestroyed(context)) {
    if (Log.isLoggable(TAG, Log.ERROR)) {
      Log.e(TAG, "Trying to load image for destroyed context");
    }
    // Nothing we can do, return
    return;
  }
  File file =
      FileMetadataUtil.getInstance()
          .getExperimentFile(appAccount, experimentId, relativeFilePath);
  if (scale) {
    // Use last modified time as part of the signature to force a glide cache refresh.
    GlideApp.with(context)
        .load(file.getAbsolutePath())
        .placeholder(R.drawable.placeholder)
        .signature(new ObjectKey(file.getPath() + file.lastModified()))
        .centerCrop()
        // caches only the final image, after reducing the resolution
        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
        .into(view);
  } else {
    // Use last modified time as part of the signature to force a glide cache refresh.
    GlideApp.with(context)
        .load(file.getAbsolutePath())
        .placeholder(R.drawable.placeholder)
        .signature(new ObjectKey(file.getPath() + file.lastModified()))
        .fitCenter()
        // caches only the final image, after reducing the resolution
        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
        .into(view);
  }
}
 
Example #10
Source File: ArtistSignatureUtil.java    From MusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
public ObjectKey getArtistSignature(String artistName, boolean isLoadOriginal, int whichImage) {
    String value = String.valueOf(getArtistSignatureRaw(artistName));
    return new ObjectKey(artistName+"_"+"original="+isLoadOriginal+"_"+"pos="+whichImage+"_"+String.valueOf(getArtistSignatureRaw(artistName)));
}
 
Example #11
Source File: AvatarLoader.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
@Override
public LoadData<InputStream> buildLoadData(@NonNull AvatarModel model, int width, int height, @NonNull Options options) {
    return new LoadData<>(new ObjectKey(model), new AvatarStreamFetcher(client, model));
}
 
Example #12
Source File: OkHttpUrlLoader.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
@Override
public LoadData<InputStream> buildLoadData(@NonNull GlideUrl model, int width, int height, @NonNull Options options) {
    return new LoadData<>(new ObjectKey(model), new ImageStreamFetcher(client, model));
}
 
Example #13
Source File: ArtistSignatureUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
public ObjectKey getArtistSignature(String artistName) {
    return new ObjectKey(String.valueOf(getArtistSignatureRaw(artistName)));
}
 
Example #14
Source File: ArtistImageLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LoadData<InputStream> buildLoadData(@NonNull ArtistImage model, int width, int height,
                                           @NonNull Options options) {
    return new LoadData<>(new ObjectKey(model.artistName), new ArtistImageFetcher(context, deezerClient, okhttp, model));
}
 
Example #15
Source File: AudioFileCoverLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LoadData<InputStream> buildLoadData(@NonNull AudioFileCover model, int width, int height,
                                           @NonNull Options options) {
    return new LoadData<>(new ObjectKey(model.filePath), new AudioFileCoverFetcher(model));
}
 
Example #16
Source File: AlbumItem.java    From Camera-Roll-Android-App with Apache License 2.0 4 votes vote down vote up
public Key getGlideSignature() {
    File file = new File(getPath());
    String lastModified = String.valueOf(file.lastModified());
    return new ObjectKey(lastModified);
}
 
Example #17
Source File: AudioFileCoverLoader.java    From MusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public LoadData<InputStream> buildLoadData(@NonNull AudioFileCover audioFileCover, int width, int height, @NonNull Options options) {
    return new LoadData<InputStream>(new ObjectKey(audioFileCover.filePath),new AudioFileCoverFetcher(audioFileCover));
}
 
Example #18
Source File: Media.java    From leafpicrevived with GNU General Public License v3.0 4 votes vote down vote up
public ObjectKey getSignature() {
    return new ObjectKey(getDateModified() + getPath() + getOrientation());
}
 
Example #19
Source File: AppIconGlideModule.java    From SoloPi with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public LoadData<ByteBuffer> buildLoadData(@NonNull String origin, int width, int height, @NonNull Options options) {
    return new LoadData<>(new ObjectKey(origin),new ApkIconFetcher(context, origin.substring(8)));
}