Search in sources :

Example 1 with CollectableItem

use of me.zhanghai.android.douya.network.api.info.frodo.CollectableItem in project Douya by DreaminginCodeZH.

the class ProfileItemAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final CollectableItem item = getItem(position);
    float ratio = 1;
    switch(item.getType()) {
        case BOOK:
        case EVENT:
        case MOVIE:
        case TV:
            ratio = 2f / 3f;
            break;
    }
    holder.itemLayout.setRatio(ratio);
    final Context context = RecyclerViewUtils.getContext(holder);
    holder.itemLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // TODO
            Intent intent = ItemActivities.makeIntent(item, context);
            if (intent != null) {
                context.startActivity(intent);
            } else {
                UriHandler.open(item.url, context);
            }
        }
    });
    ImageUtils.loadImage(holder.coverImage, item.cover.getLarge());
    holder.titleText.setText(item.title);
    // FIXME: This won't work properly if items are changed.
    ViewUtils.setVisibleOrGone(holder.dividerSpace, position != getItemCount() - 1);
}
Also used : Context(android.content.Context) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 CollectableItem (me.zhanghai.android.douya.network.api.info.frodo.CollectableItem)1