package com.ez.ertc.meeting.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.ez.ertc.meeting.R;
import com.ez.ertc.meeting.R2;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author xiezuoyuan
 * @time 2018/11/21 19:28
 */
public class LeaveDialog extends Dialog {

    private OnLeaveListener onLeaveListener;

    public LeaveDialog(@NonNull Context context, OnLeaveListener onLeaveListener) {
        super(context , R.style.ezmBottomDialog);
        this.onLeaveListener = onLeaveListener;
        getWindow().setGravity(Gravity.BOTTOM);
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(lp);
        setCanceledOnTouchOutside(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ys_mt_dialog_leave);
        ButterKnife.bind(this);
    }

    @OnClick({R2.id.btnEndMeeting,R2.id.btnLeaveMeeting, R2.id.btnCancel})
    public void onClick(View v){
        int id = v.getId();
        if (id ==R.id.btnEndMeeting){
            dismiss();
            onLeaveListener.onEnd();
        } else if (id == R.id.btnLeaveMeeting){
            dismiss();
            onLeaveListener.onLeave();
        } else if (id == R.id.btnCancel){
            dismiss();
        }
    }

    public interface OnLeaveListener {
        void onEnd();
        void onLeave();
    }

}
