package io.rong.imkit.conversation.messgelist.provider;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import io.rong.imkit.IMCenter;
import io.rong.imkit.R;
import io.rong.imkit.feature.resend.ResendManager;
import io.rong.imkit.model.UiMessage;
import io.rong.imkit.utils.FileTypeUtils;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imkit.widget.CustomMessage;
import io.rong.imkit.widget.EllipsizeTextView;
import io.rong.imkit.widget.FileRectangleProgress;
import io.rong.imkit.widget.adapter.IViewProviderListener;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Message;
import io.rong.imlib.model.MessageContent;
import io.rong.message.FileMessage;

/**
 * 群公告
 */
public class AnnouncementProvider extends BaseMessageItemProvider<CustomMessage> {

    public AnnouncementProvider() {
        mConfig.showContentBubble = false;
        mConfig.showProgress = false;
    }

    @Override
    protected ViewHolder onCreateMessageContentViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rc_text_message_item, parent, false);
        return new ViewHolder(view.getContext(), view);
    }

    @Override
    protected void bindMessageContentViewHolder(final ViewHolder holder, ViewHolder parentHolder, CustomMessage customMessage, final UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
        TextView tvAnnouncement = holder.getView(R.id.rc_text);
        tvAnnouncement.setText(customMessage.getExtra());
    }


    @Override
    protected boolean isMessageViewType(MessageContent messageContent) {
        return messageContent instanceof CustomMessage;
    }


    @Override
    public Spannable getSummarySpannable(Context context, CustomMessage customMessage) {
        return new SpannableString(customMessage.getExtra().isEmpty() ? "" : customMessage.getExtra());
    }

    @Override
    protected boolean onItemClick(ViewHolder holder, CustomMessage customMessage, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
        return false;
    }
}
