package com.sunzee.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.widget.TextViewCompat;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.sunzee.R;
import com.sunzee.model.domain.Name;
import com.sunzee.utils.SharedPreferencesUtils;
import com.sunzee.utils.UiUtil;

/**
 * 通用对话框 dialog[检查更新]
 */
public class StartCleaningDialog extends Dialog implements View.OnClickListener {

    private TextView tvTitle;
    private TextView tvContent;
    private Button btnConfirm;
    private Button btnCancel;

    public void setListener(DialogClickListener listener) {
        this.listener = listener;
    }

    private DialogClickListener listener;


    public StartCleaningDialog(Context context) {
        super(context, R.style.DialogBgD);//加载样式
        setContentView(R.layout.dialog_startclean);
        initView();
    }

    protected void initView() {
        tvTitle = findViewById(R.id.tv_title);
        tvContent = findViewById(R.id.tv_content);
        btnConfirm = findViewById(R.id.btn_confirm);
        btnCancel = findViewById(R.id.btn_cancel);
        btnConfirm.setOnClickListener(this);
        btnCancel.setOnClickListener(this);
    }
    /**
     * set button text
     *
     * @param strIdTitle title text
     * @param strId      shutdown text
     * @param strid1     open text
     */
    public void setBtnText(int strIdTitle, int content, int strId, int strid1) {
        tvTitle.setText(strIdTitle);
        tvContent.setText(content);
        btnConfirm.setText(strId);
        btnCancel.setText(strid1);
        btnCancel.setTextColor(UiUtil.getColorRes(R.color.white));
    }
    /**
     * 设置文字
     *
     * @param text
     */
    public void setContent(String text) {
        tvContent.setText(text);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_cancel:
                dismiss();
                break;
        }
        listener.onClickListener(v.getId());
    }

    public interface DialogClickListener {
        void onClickListener(int type);
    }
}
