@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); } }
@Override public void onBindViewHolder(ListViewHolder viewHolder, int position) { MediaStoreData current = data.get(position); Key signature = new MediaStoreSignature(current.mimeType, current.dateModified, current.orientation); requestBuilder .clone() .signature(signature) .load(current.uri) .into(viewHolder.image); }
@Override public RequestBuilder<Drawable> getPreloadRequestBuilder(MediaStoreData item) { MediaStoreSignature signature = new MediaStoreSignature(item.mimeType, item.dateModified, item.orientation); return requestBuilder .clone() .signature(signature) .load(item.uri); }
@NonNull @Override public RequestBuilder<GifDrawable> getPreloadRequestBuilder(MediaStoreData item) { MediaStoreSignature signature = new MediaStoreSignature(item.mimeType, item.dateModified, item.orientation); return requestBuilder .clone() .signature(signature) .load(item.uri); }
@Override public void onBindItemViewHolder(RecentPhotoViewHolder viewHolder, @NonNull Cursor cursor) { viewHolder.imageView.setImageDrawable(null); long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns._ID)); long dateTaken = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATE_TAKEN)); long dateModified = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATE_MODIFIED)); String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.MIME_TYPE)); int orientation = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION)); final Uri uri = Uri.withAppendedPath(baseUri, Long.toString(id)); Key signature = new MediaStoreSignature(mimeType, dateModified, orientation); Glide.with(getContext()) .fromMediaStore() .load(uri) .signature(signature) .diskCacheStrategy(DiskCacheStrategy.NONE) .into(viewHolder.imageView); viewHolder.imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (clickedListener != null) clickedListener.onItemClicked(uri); } }); }
public static Key createSignature(Song song) { return new MediaStoreSignature("", song.dateModified, 0); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder v = null; int type = getItem(position).getItemType(); if(convertView != null) { v = (ViewHolder)convertView.getTag(); if(v == null) { v = new ViewHolder(); v.imgView = convertView.findViewById(R.id.img); v.videoIcon = convertView.findViewById(R.id.videoIcon); } } else { convertView = attachActivity.getLayoutInflater().inflate(R.layout.picshow_img_item,null); v = new ViewHolder(); v.imgView = convertView.findViewById(R.id.img); v.videoIcon = convertView.findViewById(R.id.videoIcon); } convertView.setTag(v); if(v != null && v.imgView != null) { if(thubNailSize != 0) { GlideApp.with(attachActivity) .load(getItem(position).getPath()) .override(thubNailSize) .placeholder(R.drawable.other) .centerCrop() .dontAnimate() .format(DecodeFormat.PREFER_RGB_565) .into(v.imgView); } else { GlideApp.with(attachActivity) .load(getItem(position).getPath()) .placeholder(R.drawable.other) .centerCrop() .dontAnimate() .format(DecodeFormat.PREFER_RGB_565) .signature(new MediaStoreSignature(type == MediaSetUtils.TYPE_VIDEO ? "video/*" : "image/*" ,getItem(position).getDateToken(), 0)) .into(v.imgView); } if(type == MediaSetUtils.TYPE_VIDEO) v.videoIcon.setVisibility(View.VISIBLE); else v.videoIcon.setVisibility(View.GONE); } return convertView; }
static Key createSignature(Song song) { return new MediaStoreSignature("", song.dateModified, 0); }