Search in sources :

Example 1 with TextViewHolder

use of com.macbitsgoa.ard.viewholders.TextViewHolder in project ARD by MobileApplicationsClub.

the class NewChatAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder generalHolder, final int position) {
    if (generalHolder.getItemViewType() == TEXT) {
        final TextViewHolder holder = (TextViewHolder) generalHolder;
        if (position == admins.size() + 1)
            holder.setText("Users");
        else
            holder.setText("Admins");
    } else {
        final NewChatViewHolder holder = (NewChatViewHolder) generalHolder;
        UserItem ui;
        if (position <= admins.size())
            ui = admins.get(position - 1);
        else
            ui = users.get(position - admins.size() - 2);
        holder.setUi(ui);
    }
}
Also used : NewChatViewHolder(com.macbitsgoa.ard.viewholders.NewChatViewHolder) TextViewHolder(com.macbitsgoa.ard.viewholders.TextViewHolder) UserItem(com.macbitsgoa.ard.models.UserItem)

Example 2 with TextViewHolder

use of com.macbitsgoa.ard.viewholders.TextViewHolder in project ARD by MobileApplicationsClub.

the class PostDetailsAdapter method onCreateViewHolder.

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    final View view;
    switch(viewType) {
        case HomeType.TEXT_ITEM:
            view = inflater.inflate(R.layout.vh_big_text, parent, false);
            return new TextViewHolder(view, R.id.tv_vh_big_text);
        case HomeType.PHOTO_ITEM:
            view = inflater.inflate(R.layout.vh_big_image, parent, false);
            return new ImageViewHolder(view, parent.getContext(), R.id.imgView_vh_big_image, this);
    }
    return null;
}
Also used : ImageViewHolder(com.macbitsgoa.ard.viewholders.ImageViewHolder) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) TextViewHolder(com.macbitsgoa.ard.viewholders.TextViewHolder) NonNull(android.support.annotation.NonNull)

Aggregations

TextViewHolder (com.macbitsgoa.ard.viewholders.TextViewHolder)2 NonNull (android.support.annotation.NonNull)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 UserItem (com.macbitsgoa.ard.models.UserItem)1 ImageViewHolder (com.macbitsgoa.ard.viewholders.ImageViewHolder)1 NewChatViewHolder (com.macbitsgoa.ard.viewholders.NewChatViewHolder)1