use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class AlbumsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final AlbumsAdapter.ViewHolder holder, int position) {
// TODO Calvin: Major Refactor - No business logic here.
Album a = albums.get(position);
holder.refreshTheme(getThemeHelper(), cardViewStyle, a.isSelected());
Media f = a.getCover();
RequestOptions options = new RequestOptions().signature(f.getSignature()).format(DecodeFormat.PREFER_ARGB_8888).centerCrop().placeholder(placeholder).error(org.horaapps.leafpic.R.drawable.ic_error).diskCacheStrategy(DiskCacheStrategy.RESOURCE);
Glide.with(holder.picture.getContext()).load(f.getPath()).apply(options).into(holder.picture);
int accentColor = getThemeHelper().getAccentColor();
if (accentColor == getThemeHelper().getPrimaryColor())
accentColor = ColorPalette.getDarkerColor(accentColor);
int textColor = getThemeHelper().getColor(getThemeHelper().getBaseTheme().equals(Theme.LIGHT) ? R.color.md_album_color_2 : R.color.md_album_color);
if (a.isSelected())
textColor = getThemeHelper().getColor(R.color.md_album_color);
holder.mediaLabel.setTextColor(textColor);
holder.llCount.setVisibility(Prefs.showMediaCount() ? View.VISIBLE : View.GONE);
holder.name.setText(StringUtils.htmlFormat(a.getName(), textColor, false, true));
holder.nMedia.setText(StringUtils.htmlFormat(String.valueOf(a.getCount()), accentColor, true, false));
holder.path.setVisibility(Prefs.showAlbumPath() ? View.VISIBLE : View.GONE);
holder.path.setText(a.getPath());
// START Animation MAKES BUG ON FAST TAP ON CARD
// Animation anim;
// anim = AnimationUtils.loadAnimation(holder.albumCard.getContext(), R.anim.slide_fade_card);
// holder.albumCard.startAnimation(anim);
// ANIMS
// holder.card.animate().alpha(1).setDuration(250);
holder.card.setOnClickListener(v -> {
if (selecting()) {
notifySelected(a.toggleSelected());
notifyItemChanged(position);
} else
actionsListener.onItemSelected(position);
});
holder.card.setOnLongClickListener(v -> {
notifySelected(a.toggleSelected());
notifyItemChanged(position);
return true;
});
}
Aggregations