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

The following examples show how to use com.bumptech.glide.load.engine.DiskCacheStrategy. 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: PictureView.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 #2
Source File: ImageUtil.java    From YCAudioPlayer with 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 #3
Source File: playNowCoverPagerAdapter.java    From music_player with Open Software License 3.0 6 votes vote down vote up
@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 #4
Source File: TestListFragment.java    From glide-support with 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 #5
Source File: IconProviderAdapter.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #6
Source File: SongFileAdapter.java    From Orin with 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 #7
Source File: ImageUtils.java    From SendBird-Android with 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 #8
Source File: TinyGifDrawableLoader.java    From BaseProject with 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 #9
Source File: SectionsAdapter.java    From LeisureRead with 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 #10
Source File: GankAdapter.java    From Demo_Public with 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 #11
Source File: ZoomingImageView.java    From Silence with 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 #12
Source File: UiUtil.java    From Ticket-Analysis with 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 #13
Source File: SongFileAdapter.java    From RetroMusicPlayer with 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 #14
Source File: DemoGlideHelper.java    From GestureViews with 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 #15
Source File: ViewListAdapter.java    From GankDaily with 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 #16
Source File: AlbumAdapter.java    From Melophile with 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 #17
Source File: CommentItemDelegate.java    From ZhihuDaily with 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 #18
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 #19
Source File: UserDetailsActivity.java    From Studio with Apache License 2.0 5 votes vote down vote up
private void setupImage(ImageView image, String imageUrl) {
    if (imageUrl == null || imageUrl.length() == 0)
        return;
    requestManager.load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.defimgs)
            .into(image);
}
 
Example #20
Source File: MediaFileAdapter.java    From PLDroidShortVideo with Apache License 2.0 5 votes vote down vote up
public MediaFileAdapter(Context context, int type, List dataSource) {
    mContext = context;
    mType = type;
    mDataSource = new ArrayList<>();
    if (dataSource != null) {
        mDataSource.addAll(dataSource);
    }
    int itemWidth = calculateItemSize();
    mRequestOptions = new RequestOptions()
            .centerCrop()
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .override(itemWidth, itemWidth);
}
 
Example #21
Source File: ImageLoader.java    From LbaizxfPulltoRefresh with Apache License 2.0 5 votes vote down vote up
/**
 * 图片加载
 * @author leibing
 * @createTime 2016/8/15
 * @lastModify 2016/8/15
 * @param context 上下文
 * @param imageView 图片显示控件
 * @param localPath 图片本地链接
 * @param defaultImage 默认占位图片
 * @param errorImage 加载失败后图片
 * @param  isCropCircle 是否圆角
 * @return
 */
public void load(Context context, ImageView imageView, File localPath, Drawable defaultImage, Drawable errorImage , boolean isCropCircle){
    // 图片加载库采用Glide框架
    DrawableTypeRequest request = Glide.with(context).load(localPath);
    // 设置scaleType
    request.centerCrop();
    // 圆角裁切
    if (isCropCircle)
        request.bitmapTransform(new CropCircleTransformation(context));
    request.thumbnail(0.1f) //用原图的1/10作为缩略图
            .placeholder(defaultImage) //设置资源加载过程中的占位Drawable
            .crossFade() //设置加载渐变动画
            .priority(Priority.NORMAL) //指定加载的优先级,优先级越高越优先加载,
            // 但不保证所有图片都按序加载
            // 枚举Priority.IMMEDIATE,Priority.HIGH,Priority.NORMAL,Priority.LOW
            // 默认为Priority.NORMAL
            .fallback(null) //设置model为空时要显示的Drawable
            // 如果没设置fallback,model为空时将显示error的Drawable,
            // 如果error的Drawable也没设置,就显示placeholder的Drawable
            .error(errorImage) //设置load失败时显示的Drawable
            .skipMemoryCache(true) //设置跳过内存缓存,但不保证一定不被缓存
            // (比如请求已经在加载资源且没设置跳过内存缓存,这个资源就会被缓存在内存中)
            .diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略DiskCacheStrategy.SOURCE:
            // 缓存原始数据,DiskCacheStrategy.RESULT:
            // 缓存变换(如缩放、裁剪等)后的资源数据,
            // DiskCacheStrategy.NONE:什么都不缓存,
            // DiskCacheStrategy.ALL:缓存SOURC和RESULT。
            // 默认采用DiskCacheStrategy.RESULT策略,
            // 对于download only操作要使用DiskCacheStrategy.SOURCE
            .into(imageView);
}
 
Example #22
Source File: SplashActivity.java    From ZhihuDaily with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestError() {
    imgUrl = (String) SharedPreferencesUtils.get(App.getContext(), "launch_image", "");
    if (TextUtils.isEmpty(imgUrl)) {
        Glide.with(this)
                .load(imgUrl)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(launchImage);
    }
}
 
Example #23
Source File: ImageUtil.java    From social-app-android with Apache License 2.0 5 votes vote down vote up
public static void loadLocalImage(GlideRequests glideRequests, Uri uri, ImageView imageView,
                                  RequestListener<Drawable> listener) {
    glideRequests.load(uri)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .fitCenter()
            .listener(listener)
            .into(imageView);
}
 
Example #24
Source File: PictureActivity.java    From Studio with Apache License 2.0 5 votes vote down vote up
private void setupImage(ImageView image, String imageUrl) {
    if (imageUrl == null || imageUrl.length() == 0)
        return;
    requestManager.load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.defimgs)
            .into(image);
}
 
Example #25
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void loadImage(Context context, ImageView view,
                             @NonNull String url, @DrawableRes int thumbResId, @Size(2) @Px int[] size,
                             @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    DrawableRequestBuilder<Integer> thumb = thumbResId == 0 ? null : Glide.with(getValidContext(context))
            .load(thumbResId)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .listener(new BaseRequestListener<>(() -> view.setTag(R.id.tag_item_image_fade_in_flag, false)));
    loadImage(context, view, url, thumb, size, ts, l);
}
 
Example #26
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")
			.diskCacheStrategy(DiskCacheStrategy.NONE) // force reload
			.skipMemoryCache(true) // force reload
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(imageView)
	;
}
 
Example #27
Source File: AudioPlayingButton.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
public void setCoverImage(String image) {
    Glide.with(this).load(image)
            .apply(new RequestOptions().dontAnimate().centerCrop()
                    .transform(new CenterCrop(), new CircleCrop())
                    .error(R.drawable.img_cover_default)
                    .placeholder(R.drawable.img_cover_default)
                    .diskCacheStrategy(DiskCacheStrategy.RESOURCE))
            .into(ivCover);
}
 
Example #28
Source File: ImageLoaderUtils.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
public static void displayRound(Context context,ImageView imageView, String url) {
    if (imageView == null) {
        throw new IllegalArgumentException("argument error");
    }
    Glide.with(context).load(url)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .error(R.drawable.toux2)
            .centerCrop().transform(new GlideRoundTransformUtil(context)).into(imageView);
}
 
Example #29
Source File: MainActivity.java    From TestChat with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        switch (requestCode) {
            case Constant.REQUEST_CODE_EDIT_USER_INFO:
                user = (User) data.getSerializableExtra("user");
                nick.setText(user.getNick());
                signature.setText(user.getSignature());
                Glide.with(this).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).into(icon_1);
                ToastUtils.showShortToast("保存个人信息成功");
                Glide.with(this).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).into(avatar);
                break;
            case Constant.REQUEST_CODE_WEATHER_INFO:
                LogUtil.e("返回天气数据");
                WeatherInfoBean weatherInfoBean = (WeatherInfoBean) data.getSerializableExtra("WeatherInfo");
                if (weatherInfoBean != null) {
                    mWeatherInfoBean = weatherInfoBean;
                    weatherCity.setText(mWeatherInfoBean.getCity());
                    weatherTemperature.setText(mWeatherInfoBean.getTemperature());
                }
                break;
            case Constant.REQUEST_CODE_SELECT_WALLPAPER:
                updateMenuBg();
                break;
        }
    }
}
 
Example #30
Source File: ImageViewActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
public MediaPagerAdapter(Context context, List<MediaInfo> listMedia)
{
    super();
    this.context = context;
    this.listMedia = listMedia;
    imageRequestOptions = new RequestOptions().centerInside().diskCacheStrategy(DiskCacheStrategy.NONE).error(R.drawable.broken_image_large);
}