Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Glide cache pettern

FujiKinaga
November 06, 2017

Glide cache pettern

v3とv4で比較してみた

FujiKinaga

November 06, 2017
Tweet

More Decks by FujiKinaga

Other Decks in Technology

Transcript

  1. ProfilePic in Player BG with blur in Player NotificationIcon CollabIcon

    in Player CommentPic in Player ProfilePic in Feed
  2. - ProfilePic in Feed int scaledPix = AppUtils.dpToPx(128, contactViewHolder.mImgProfilePic.getResources()); Glide.with(contactViewHolder.mImgProfilePic.getContext())

    .load(AppUtils.getFeedProfilePicUrl(feed)) .override(scaledPix, scaledPix) .placeholder(R.drawable.ic_feed_placeholder) .into(contactViewHolder.mImgProfilePic); - ProfilePic in Player int scaledPixImgRound = getResources().getDimensionPixelSize(R.dimen.player_user_image_size); ← 100dp Glide.with(getContext()) .load(AppUtils.getFeedProfilePicUrl(feed)) .bitmapTransform(new CropCircleTransformation(getContext())) .override(scaledPixImgRound, scaledPixImgRound) .into(mUserImg); - CollaborationIcon in Feed int scaledPix = AppUtils.dpToPx(32, NanaApplication.getContext().getResources()); Glide.with(NanaApplication.getContext()) .load(url) .asBitmap() .override(scaledPix, scaledPix) .centerCrop() .into(new BitmapImageViewTarget(contactViewHolder.mLstCollabImages.get(currentIndex)) { @Override protected void setResource(Bitmap resource) { if (contactViewHolder.mLstCollabImages != null && contactViewHolder.mLstCollabImages.get(currentIndex) != null) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(contactViewHolder.mLstCollabImages.get(currentIndex).getResources(), resource); circularBitmapDrawable.setCircular(true); - CollaborationIcon in Player int scaleRatioCollab = getResources().getDimensionPixelSize(R.dimen.player_collab_user_size); ← 36dp Glide.with(getContext()) .load(picUrl) .bitmapTransform(new CropCircleTransformation(getContext())) .override(scaleRatioCollab, scaleRatioCollab) .into(mCollabImage);
  3. - ProfilePic in Feed int scaledPix = AppUtils.dpToPx(128, contactViewHolder.mImgProfilePic.getResources()); Glide.with(contactViewHolder.mImgProfilePic.getContext())

    .load(AppUtils.getFeedProfilePicUrl(feed)) .asBitmap() .override(scaledPix, scaledPix) .centerCrop() - ProfilePic in Player int scaledPix = AppUtils.dpToPx(128, getResources()); Glide.with(getContext()) .load(description.getIconUri().toString()) .asBitmap() .override(scaledPix, scaledPix) .centerCrop() .transform(new CropCircleTransformation(getContext())) .into(mUserImg); - CollaborationIcon in Feed int scaledPix = AppUtils.dpToPx(48, contactViewHolder.mLstCollabImages.get(currentIndex).getResources()); Glide.with(contactViewHolder.mLstCollabImages.get(currentIndex).getContext()) .load(url) .asBitmap() .override(scaledPix, scaledPix) .centerCrop() .transform(new CropCircleTransformation(contactViewHolder.mLstCollabImages.get(currentIndex).getContext())) - CollaborationIcon in Player int scaledPix = AppUtils.dpToPx(48, getResources()); Glide.with(getContext()) .load(picUrl) .asBitmap() .override(scaledPix, scaledPix) .centerCrop() .transform(new CropCircleTransformation(getContext()))
  4. Notice • Cache format (Drawable, Bitmap, Gif…) • Load url

    • .override (int width, int height) • .transform (Blur, Brightness, Color, Circle…) • DiskCacheStrategy