Search in sources :

Example 11 with Album

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;
    });
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Media(org.horaapps.leafpic.data.Media) Album(org.horaapps.leafpic.data.Album)

Aggregations

Album (org.horaapps.leafpic.data.Album)11 Media (org.horaapps.leafpic.data.Media)7 File (java.io.File)5 ArrayList (java.util.ArrayList)3 Cursor (android.database.Cursor)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 InputStream (java.io.InputStream)2 SortingOrder (org.horaapps.leafpic.data.sort.SortingOrder)2 Security (org.horaapps.leafpic.util.Security)2 DeleteException (org.horaapps.leafpic.util.file.DeleteException)2 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 Configuration (android.content.res.Configuration)1