Search in sources :

Example 86 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project ChipsLayoutManager by BelooS.

the class RecyclerViewAdapter method onCreateViewHolder.

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView;
    switch(viewType) {
        case ITEM_TYPE_INCREASED:
            itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_increased, parent, false);
            break;
        default:
            itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_simple, parent, false);
            break;
    }
    viewHolderCount++;
    //        Timber.w(TAG, "created holders = " + viewHolderCount);
    return new ViewHolder(itemView);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 87 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project Douya by DreaminginCodeZH.

the class SingleBroadcastAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Broadcast broadcast = mBroadcast;
    holder.broadcastLayout.bindBroadcast(broadcast);
    holder.broadcastLayout.setListener(new BroadcastLayout.Listener() {

        @Override
        public void onLikeClicked() {
            mListener.onLike(broadcast, !broadcast.isLiked);
        }

        @Override
        public void onRebroadcastClicked() {
            mListener.onRebroadcast(broadcast, !broadcast.isRebroadcasted());
        }

        @Override
        public void onCommentClicked() {
            mListener.onComment(broadcast);
        }
    });
    holder.viewActivityButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mListener.onViewActivity(broadcast);
        }
    });
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) BindView(butterknife.BindView)

Example 88 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder 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)

Example 89 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project Douya by DreaminginCodeZH.

the class BaseUserAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Context context = RecyclerViewUtils.getContext(holder);
    final SimpleUser user = getItem(position);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            context.startActivity(ProfileActivity.makeIntent(user, context));
        }
    });
    ImageUtils.loadAvatar(holder.avatarImage, user.avatar);
    holder.nameText.setText(user.name);
    //noinspection deprecation
    holder.descriptionText.setText(user.uid);
}
Also used : Context(android.content.Context) SimpleUser(me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 90 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project Douya by DreaminginCodeZH.

the class NotificationAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Context context = RecyclerViewUtils.getContext(holder);
    final Notification notification = getItem(position);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mListener != null) {
                mListener.onMarkNotificationAsRead(notification);
            }
            UriHandler.open(notification.targetUri, context);
        }
    });
    holder.textText.setText(notification.text);
    holder.textText.setTextColor(notification.read ? mTextColorSecondary : mTextColorPrimary);
    holder.timeText.setDoubanTime(notification.time);
}
Also used : Context(android.content.Context) TimeTextView(me.zhanghai.android.douya.ui.TimeTextView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)265 View (android.view.View)248 TextView (android.widget.TextView)129 ImageView (android.widget.ImageView)95 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)47 LayoutInflater (android.view.LayoutInflater)34 ViewGroup (android.view.ViewGroup)32 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)28 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 Intent (android.content.Intent)26 ArrayList (java.util.ArrayList)25 Context (android.content.Context)21 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)17 BindView (butterknife.BindView)17 CardView (android.support.v7.widget.CardView)15 Paint (android.graphics.Paint)11 ParallaxRecyclerAdapter (com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter)8 ExampleData (de.madcyph3r.example.data.ExampleData)8 Drawable (android.graphics.drawable.Drawable)7 Test (org.junit.Test)7