Search in sources :

Example 1 with ImageViewHolder

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

the class ChatMsgAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
    MessageItem mi = messages.get(position);
    if (mi.hasAttachments()) {
        DocumentItem di = mi.getDocuments().get(0);
        if (!di.getLocalUri().equals("") && di.getMimeType().contains("image")) {
            ImageViewHolder imvh = (ImageViewHolder) holder;
            String imageUrl = di.getLocalThumbnailUri();
            if (imageUrl == null)
                imageUrl = di.getLocalUri();
            if (imageUrl == null)
                imageUrl = di.getRemoteThumbnailUrl();
            if (imageUrl == null)
                imageUrl = di.getRemoteUrl();
            imvh.setUri(Uri.parse(di.getLocalUri()), Uri.parse(imageUrl), RequestOptions.centerCropTransform());
        } else {
            ((ImageViewHolder) holder).setUri(di.getLocalUri(), AHC.getImageUrlFromMimeType(di.getMimeType()));
        }
    } else if (holder.getItemViewType() == RECEIVER || holder.getItemViewType() == SENDER) {
        ChatMsgViewHolder cmvh = (ChatMsgViewHolder) holder;
        cmvh.populate(mi);
        if (position < getItemCount() - 1 && getItemViewType(position + 1) == holder.getItemViewType()) {
            cmvh.emptySpace.setVisibility(View.GONE);
        } else
            cmvh.emptySpace.setVisibility(View.VISIBLE);
    }
}
Also used : MessageItem(com.macbitsgoa.ard.models.MessageItem) ImageViewHolder(com.macbitsgoa.ard.viewholders.ImageViewHolder) ChatMsgViewHolder(com.macbitsgoa.ard.viewholders.ChatMsgViewHolder) DocumentItem(com.macbitsgoa.ard.models.DocumentItem)

Example 2 with ImageViewHolder

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

the class ChatMsgAdapter method onCreateViewHolder.

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    if (viewType == RECEIVER || viewType == SENDER) {
        final View view = inflater.inflate(R.layout.vh_activity_chat_chatmsg, parent, false);
        final LinearLayout root = view.findViewById(R.id.ll_chatmsg_root);
        final LinearLayout msgBox = view.findViewById(R.id.ll_chatmsg_msg_box);
        if (viewType == RECEIVER) {
            root.setGravity(Gravity.END);
            msgBox.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.bg_chat_rcv));
        } else if (viewType == SENDER) {
            root.setGravity(Gravity.START);
            msgBox.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.bg_chat_sen));
        }
        final TextView messageTv = view.findViewById(R.id.textView_viewHolder_chatmsg_msg);
        final int msgMaxWidth = (int) (AHC.getScreenWidth() * MAX_WIDTH_FRACTION);
        messageTv.setMaxWidth(msgMaxWidth);
        return new ChatMsgViewHolder(view);
    } else {
        final View view = inflater.inflate(R.layout.vh_chat_document, parent, false);
        return new ImageViewHolder(view, context, R.id.imgView_vh_chat_document, this);
    }
}
Also used : ChatMsgViewHolder(com.macbitsgoa.ard.viewholders.ChatMsgViewHolder) ImageViewHolder(com.macbitsgoa.ard.viewholders.ImageViewHolder) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout) NonNull(android.support.annotation.NonNull)

Example 3 with ImageViewHolder

use of com.macbitsgoa.ard.viewholders.ImageViewHolder 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

ImageViewHolder (com.macbitsgoa.ard.viewholders.ImageViewHolder)3 NonNull (android.support.annotation.NonNull)2 RecyclerView (android.support.v7.widget.RecyclerView)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ChatMsgViewHolder (com.macbitsgoa.ard.viewholders.ChatMsgViewHolder)2 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 DocumentItem (com.macbitsgoa.ard.models.DocumentItem)1 MessageItem (com.macbitsgoa.ard.models.MessageItem)1 TextViewHolder (com.macbitsgoa.ard.viewholders.TextViewHolder)1