Search in sources :

Example 1 with TriangleDrawable

use of com.hippo.drawable.TriangleDrawable in project EhViewer by seven332.

the class GalleryAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(GalleryHolder holder, int position) {
    GalleryInfo gi = getDataAt(position);
    if (null == gi) {
        return;
    }
    switch(mType) {
        default:
        case TYPE_LIST:
            {
                holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
                holder.title.setText(EhUtils.getSuitableTitle(gi));
                holder.uploader.setText(gi.uploader);
                holder.rating.setRating(gi.rating);
                TextView category = holder.category;
                String newCategoryText = EhUtils.getCategory(gi.category);
                if (!newCategoryText.equals(category.getText())) {
                    category.setText(newCategoryText);
                    category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
                }
                holder.posted.setText(gi.posted);
                holder.simpleLanguage.setText(gi.simpleLanguage);
                break;
            }
        case TYPE_GRID:
            {
                ((TileThumb) holder.thumb).setThumbSize(gi.thumbWidth, gi.thumbHeight);
                holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
                View category = holder.category;
                Drawable drawable = category.getBackground();
                int color = EhUtils.getCategoryColor(gi.category);
                if (!(drawable instanceof TriangleDrawable)) {
                    drawable = new TriangleDrawable(color);
                    category.setBackgroundDrawable(drawable);
                } else {
                    ((TriangleDrawable) drawable).setColor(color);
                }
                holder.simpleLanguage.setText(gi.simpleLanguage);
                break;
            }
    }
    // Update transition name
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long gid = gi.gid;
        holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
    }
}
Also used : GalleryInfo(com.hippo.ehviewer.client.data.GalleryInfo) Drawable(android.graphics.drawable.Drawable) TriangleDrawable(com.hippo.drawable.TriangleDrawable) TextView(android.widget.TextView) TriangleDrawable(com.hippo.drawable.TriangleDrawable) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 TriangleDrawable (com.hippo.drawable.TriangleDrawable)1 GalleryInfo (com.hippo.ehviewer.client.data.GalleryInfo)1