package xn.hxp.weidith;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ClickUtils;
import com.lxj.xpopup.core.AttachPopupView;

import xn.hxp.R;

public class CustomAttachPopup extends AttachPopupView {
    private String msg;

    public CustomAttachPopup(@NonNull Context context, String msg) {
        super(context);
        this.msg = msg;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.custom_bubble_attach_popup;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        if (TextUtils.isEmpty(msg)) {
            dismiss();
            return;
        }
        TextView textView = findViewById(R.id.tv);
        textView.setText(msg);
        textView.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
            @Override
            public void onDebouncingClick(View v) {
                dismiss();
            }
        });
    }
}
