package com.baijiayun.live.ui.chat;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;

import com.baijiayun.live.ui.R;
import com.baijiayun.livecore.context.LiveRoom;
import com.baijiayun.livecore.models.imodels.IMessageModel;
import com.baijiayun.liveuibase.widgets.chat.FloatChatMessageCommonAdapter;

import java.util.Objects;

public class FloatingChatFullScreenAdapter extends FloatChatMessageCommonAdapter {

    public FloatingChatFullScreenAdapter(@NonNull Context context, @NonNull LiveRoom liveRoom) {
        super(context, liveRoom);
    }

    @Override
    public Drawable setItemBackground() {
        return Objects.requireNonNull(ResourcesCompat.getDrawable(getContext().getResources(), R.drawable.bjy_bg_item_ppt_floating_recycler, null));
    }

    @NonNull
    @Override
    public TextViewHolder createTextViewHolder(@NonNull ViewGroup parent) {
        return new TextViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.bjy_item_tv_ppt_floating_recycler, parent, false));
    }

    @NonNull
    @Override
    public ImageViewHolder createImageViewHolder(@NonNull ViewGroup parent) {
        return new ImageViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.bjy_item_iv_ppt_floating_recycler, parent, false));
    }

    @Override
    public int maxChatCount() {
        return 3;
    }

    @Override
    public int setDisplayTime() {
        return 5000;
    }

    @Override
    public boolean shouldNameAppendToTextContent() {
        return false;
    }

    @Override
    public boolean filterWhenMsgAdd(@NonNull IMessageModel message) {
        return true;
    }

    static class TextViewHolder extends FloatChatMessageCommonAdapter.TextViewHolder {

        public TextViewHolder(@NonNull View itemView) {
            super(itemView);
            setContentTextView(itemView.findViewById(R.id.float_chat_content_tv));
            setUserNameTextView(itemView.findViewById(R.id.float_chat_user_tv));
        }
    }

    static class ImageViewHolder extends FloatChatMessageCommonAdapter.ImageViewHolder {

        public ImageViewHolder(@NonNull View itemView) {
            super(itemView);
            setContentImageView(itemView.findViewById(R.id.float_img_msg_iv));
            setUserNameTextView(itemView.findViewById(R.id.float_chat_user_tv));
        }
    }
}
