package com.bokecc.livemodule.live.room;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bokecc.dwlivedemo.R;
import com.bokecc.livemodule.view.BaseRelativeLayout;

/**
 * Copyright (C), 20105-2021, 创盛视联数码科技（北京）有限公司
 * FileName:
 * Author:
 * Date: 2023/1/12
 * Description:
 */
public class NoticeFloatLayout extends BaseRelativeLayout {

    private TextView tvNoticeFloatContent;
    private ImageView ivNoticeFloatClose;

    public NoticeFloatLayout(Context context) {
        super(context);
    }

    public NoticeFloatLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoticeFloatLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void initViews() {
        View rootView = View.inflate(getContext(), R.layout.layout_live_notice_float,this);

        tvNoticeFloatContent = rootView.findViewById(R.id.tv_notice_float_content);
        ivNoticeFloatClose = rootView.findViewById(R.id.iv_notice_float_close);

        ivNoticeFloatClose.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                NoticeFloatLayout.this.setVisibility(GONE);
                showNoticeOpenTips();
            }
        });
    }

    private void showNoticeOpenTips() {
        if (noticeFloatListener!=null){
            noticeFloatListener.onShowTips();
        }
    }


    public void setNotice(String notice){
        tvNoticeFloatContent.setText(notice);
    }


    private OnNoticeFloatListener noticeFloatListener;

    public void setNoticeFloatListener(OnNoticeFloatListener noticeFloatListener) {
        this.noticeFloatListener = noticeFloatListener;
    }

    public interface OnNoticeFloatListener{
        void onShowTips();
    }
}
