Java Code Examples for com.bumptech.glide.Glide#clear()

The following examples show how to use com.bumptech.glide.Glide#clear() . 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: arrayAdapter.java    From TinderClone with MIT License 6 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent){
    cards card_item = getItem(position);

    if (convertView == null){
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.item, parent, false);
    }

    TextView name = (TextView) convertView.findViewById(R.id.name);
    ImageView image = (ImageView) convertView.findViewById(R.id.image);

    name.setText(card_item.getName());
    switch(card_item.getProfileImageUrl()){
        case "default":
            Glide.with(convertView.getContext()).load(R.mipmap.ic_launcher).into(image);
            break;
        default:
            Glide.clear(image);
            Glide.with(convertView.getContext()).load(card_item.getProfileImageUrl()).into(image);
            break;
    }


    return convertView;

}
 
Example 2
Source File: ThumbnailView.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public void setImageResource(@NonNull MasterSecret masterSecret, @NonNull Slide slide, boolean showControls) {
  if (showControls) {
    getTransferControls().setSlide(slide);
    getTransferControls().setDownloadClickListener(new DownloadClickDispatcher());
  } else if (transferControls.isPresent()) {
    getTransferControls().setVisibility(View.GONE);
  }

  if (slide.getThumbnailUri() != null && slide.hasPlayOverlay() && slide.getTransferState() == AttachmentDatabase.TRANSFER_PROGRESS_DONE) {
    this.playOverlay.setVisibility(View.VISIBLE);
  } else {
    this.playOverlay.setVisibility(View.GONE);
  }

  if (Util.equals(slide, this.slide)) {
    Log.w(TAG, "Not re-loading slide " + slide.asAttachment().getDataUri());
    return;
  }

  if (!isContextValid()) {
    Log.w(TAG, "Not loading slide, context is invalid");
    return;
  }

  Log.w(TAG, "loading part with id " + slide.asAttachment().getDataUri()
             + ", progress " + slide.getTransferState());

  this.slide = slide;

  if      (slide.getThumbnailUri() != null) buildThumbnailGlideRequest(slide, masterSecret).into(image);
  else if (slide.hasPlaceholder())          buildPlaceholderGlideRequest(slide).into(image);
  else                                      Glide.clear(image);
}
 
Example 3
Source File: DetailFragmentWithPager.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override public void destroyItem(ViewGroup container, int position, Object object) {
	ImageView imageView = (ImageView)object;
	Glide.clear(imageView);
	if (position != 0) { // keep main image as child so on leave transition it can be animated
		container.removeView(imageView);
	}
}
 
Example 4
Source File: JiandanMeiziAdapter.java    From MoeQuest with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ClickableViewHolder holder, int position) {

  if (holder instanceof ItemViewHolder) {
    ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
    JianDanMeizi.JianDanMeiziData jianDanMeiziData = datas.get(position);
    String picUrl;
    if (jianDanMeiziData.pics[0].endsWith(".gif")) {
      picUrl = jianDanMeiziData.pics[0]
          .replace("mw600", "small")
          .replace("mw690", "small")
          .replace("mw1200", "small")
          .replace("mw1024", "small")
          .replace("large", "small");
      LogUtil.all(picUrl);
    } else {
      picUrl = jianDanMeiziData.pics[0];
    }

    Glide.clear(itemViewHolder.mImage);
    Glide.with(getContext())
        .load(picUrl)
        .asBitmap()
        .centerCrop()
        .placeholder(R.drawable.placeholder_image)
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        //.override(200, 250)
        .into(itemViewHolder.mImage);

    itemViewHolder.mDesc.setText(datas.get(position).commentAuthor);
    itemViewHolder.mDate.setText(datas.get(position).commentDate);
  }

  super.onBindViewHolder(holder, position);
}
 
Example 5
Source File: playNowCoverPagerAdapter.java    From music_player with Open Software License 3.0 5 votes vote down vote up
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    ImageView imageView = (ImageView) object;
    if (imageView == null)
        return;
    Glide.clear(imageView);     //核心,解决OOM
    container.removeView(imageView);
}
 
Example 6
Source File: TaoFemaleAdapter.java    From MoeQuest with Apache License 2.0 5 votes vote down vote up
private void setImageList(final ItemViewHolder itemViewHolder, final ArrayList<String> imgList, final String url, final String name) {

    Glide.clear(itemViewHolder.mImage);
    Glide.with(getContext())
        .load(url)
        .centerCrop()
        .placeholder(R.drawable.placeholder_image)
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(itemViewHolder.mImage);

    itemViewHolder.mImageNum.setText(imgList.size() + "张");

    itemViewHolder.mImage.setOnClickListener(v -> {

      if (imgList.size() > 0) {
        TaoFemalePagerActivity.luancher((Activity) getContext(), imgList, 0);
      } else {
        Intent intent = SingleMeiziDetailsActivity.LuanchActivity((Activity) mContext, url, name);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
          mContext.startActivity(intent,
              ActivityOptions.makeSceneTransitionAnimation((Activity) mContext,
                  itemViewHolder.mImage, "transitionImg").toBundle());
        } else {
          mContext.startActivity(intent);
        }
      }
    });
  }
 
Example 7
Source File: VideoItem.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recycle(@Nonnull View view)
{
    VideoViewHolder holder = getViewHolder(view);
    if (holder != null)
    {
        Glide.clear(getViewHolder(view).mVideoView);
    }
}
 
Example 8
Source File: ExplorerActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public void clearCache(View v) {
    Log.d(TAG, "clearing cache");
    Glide.clear(v);
    //Glide.clear(imageViewNet);
    Glide.get(this).clearMemory();
    File cacheDir = Glide.getPhotoCacheDir(this);
    if (cacheDir.isDirectory()) {
        for (File child : cacheDir.listFiles()) {
            if (!child.delete()) {
                Log.w(TAG, "cannot delete: " + child);
            }
        }
    }
    //reload();
}
 
Example 9
Source File: FullscreenImageActivity.java    From Anecdote with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    if (mPhotoView != null) {
        Glide.clear(mPhotoView);
    }
}
 
Example 10
Source File: GlideBaseImageFragment.java    From glide-support with The Unlicense 4 votes vote down vote up
protected void clear(ImageView imageView) {
	Glide.clear(imageView);
}
 
Example 11
Source File: TrackAdapter.java    From GPSLogger with GNU General Public License v3.0 4 votes vote down vote up
void BindTrack(Track trk) {
    track = trk;

    card.setSelected(track.isSelected());

    imageViewPulse.setVisibility(View.INVISIBLE);
    textViewTrackName.setText(track.getName());
    textViewTrackDescription.setText(GPSApplication.getInstance().getString(R.string.track_id) + " " + track.getId());

    if (trk.getNumberOfLocations() >= 1) {
        phd = phdformatter.format(track.getEstimatedDistance(),PhysicalDataFormatter.FORMAT_DISTANCE);
        textViewTrackLength.setText(phd.Value + " " + phd.UM);
        phd = phdformatter.format(track.getPrefTime(),PhysicalDataFormatter.FORMAT_DURATION);
        textViewTrackDuration.setText(phd.Value);
        phd = phdformatter.format(track.getEstimatedAltitudeGap(GPSApplication.getInstance().getPrefEGM96AltitudeCorrection()),PhysicalDataFormatter.FORMAT_ALTITUDE);
        textViewTrackAltitudeGap.setText(phd.Value + " " + phd.UM);
        phd = phdformatter.format(track.getSpeedMax(),PhysicalDataFormatter.FORMAT_SPEED);
        textViewTrackMaxSpeed.setText(phd.Value + " " + phd.UM);
        phd = phdformatter.format(track.getPrefSpeedAverage(),PhysicalDataFormatter.FORMAT_SPEED_AVG);
        textViewTrackAverageSpeed.setText(phd.Value + " " + phd.UM);
    } else {
        textViewTrackLength.setText("");
        textViewTrackDuration.setText("");
        textViewTrackAltitudeGap.setText("");
        textViewTrackMaxSpeed.setText("");
        textViewTrackAverageSpeed.setText("");
    }
    textViewTrackGeopoints.setText(String.valueOf(track.getNumberOfLocations()));
    textViewTrackPlacemarks.setText(String.valueOf(track.getNumberOfPlacemarks()));

    TT = trk.getTrackType();
    if (TT != NOT_AVAILABLE) imageViewIcon.setImageBitmap(bmpTrackType[TT]);
    else imageViewIcon.setImageBitmap(null);

    if (GPSApplication.getInstance().getCurrentTrack().getId() == track.getId()) {
        imageViewThumbnail.setImageBitmap (GPSApplication.getInstance().getRecording() ? bmpCurrentTrackRecording : bmpCurrentTrackPaused);
    }
    else {
        Glide.clear(imageViewThumbnail);
        Glide
                .with(GPSApplication.getInstance().getApplicationContext())
                .load(GPSApplication.getInstance().getApplicationContext().getFilesDir().toString() + "/Thumbnails/" + track.getId() + ".png")
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                //.skipMemoryCache(true)
                .error(null)
                .dontAnimate()
                .into(imageViewThumbnail);
    }
}
 
Example 12
Source File: GlideLoader.java    From ImageLoader with Apache License 2.0 4 votes vote down vote up
@Override
public void clearMomoryCache(View view) {
    Glide.clear(view);
}
 
Example 13
Source File: ImageViewHolder.java    From Anecdote with Apache License 2.0 4 votes vote down vote up
/**
 * Reset glide listener and retry count on view unbind/new data
 */
private void reset(){
    mRetried = 0;
    Glide.clear(mImageView);
}
 
Example 14
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewRecycled(PhotoViewHolder holder) {
    Glide.clear(holder.ivPhoto);
    super.onViewRecycled(holder);
}
 
Example 15
Source File: GlideBaseImageActivity.java    From glide-support with The Unlicense 4 votes vote down vote up
protected void clear(ImageView imageView) {
	Glide.clear(imageView);
}
 
Example 16
Source File: ThumbnailView.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
public void clear() {
  if (isContextValid())             Glide.clear(image);
  if (transferControls.isPresent()) getTransferControls().clear();

  slide = null;
}
 
Example 17
Source File: AlbumHolder.java    From BeMusic with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewRecycled(Context context) {
    super.onViewRecycled(context);
    Glide.clear(thumbIv);
}
 
Example 18
Source File: SongHolder.java    From BeMusic with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewRecycled(Context context) {
    super.onViewRecycled(context);
    Glide.clear(thumbIv);
}
 
Example 19
Source File: PreloadTarget.java    From giffun with Apache License 2.0 4 votes vote down vote up
@Override
public void onResourceReady(Z resource, GlideAnimation<? super Z> glideAnimation) {
    Glide.clear(this);
}
 
Example 20
Source File: ImageLoader.java    From LbaizxfPulltoRefresh with Apache License 2.0 2 votes vote down vote up
/**
 * 清除view缓存
 * @author leibing
 * @createTime 2016/8/15
 * @lastModify 2016/8/15
 * @param view
 * @return
 */
public void clearViewCache(View view){
    // 图片加载库采用Glide框架
    Glide.clear(view);
}