package com.sunzee.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.sunzee.R;
import com.sunzee.utils.LongClickUtils;
import com.sunzee.utils.UiUtil;
import com.wuxiaolong.androidutils.library.LogUtil;

/**
 * @Description 警报框
 */
public class WarringDialog extends Dialog {
    private Context mContext;
    private TextView tvContent;
    private TextView tvContent1;
    private Button btnDimiss, btnDimiss1;
    private boolean isTouch;
    private ImageView mIvImg;

    public WarringDialog(@NonNull Context context) {
        super(context, R.style.DialogBgD);//加载样式
        mContext = context;
        setContentView(R.layout.dialog_text);
        initView();
        initEvent();
    }

    private void initEvent() {
        //长按3秒
        LongClickUtils.setLongClick(new Handler(), mIvImg, 3000, new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                dismiss();
                return false;
            }
        });
    }

    private void initView() {
        tvContent = findViewById(R.id.tv_content);
        tvContent1 = findViewById(R.id.tv_content1);
        btnDimiss = findViewById(R.id.btn_dimiss);
        btnDimiss1 = findViewById(R.id.btn_dimiss1);
        mIvImg = findViewById(R.id.iv_img);
    }

    public void setIvImag(int resId) {
    }

    @Override
    public void show() {
        super.show();
        isTouch = false;
        LogUtil.d("WarringDialog", "show");
    }
    public void setTvContent(int strId) {
        tvContent.setText(strId);
//        switch (strId) {
//            case R.string.warring_gunhechugun:
//                mIvImg.setImageResource(R.drawable.warring_gunhequegunbaojing);
//                break;
//            case R.string.warring_gunhequegunbaojing:
//                mIvImg.setImageResource(R.drawable.warring_gunhequegunbaojing);
//                break;
//            case R.string.warring_qshqs:
//                mIvImg.setImageResource(R.drawable.warring_qshqs);
//                break;
//            case R.string.warring_fsm:
//                mIvImg.setImageResource(R.drawable.warring_fsm);
//                break;
//            case R.string.warring_qbt:
//                mIvImg.setImageResource(R.drawable.warring_qbt);
//                break;
//            case R.string.warring_qht:
//                mIvImg.setImageResource(R.drawable.warring_qht);
//                break;
//            case R.string.warring_qhuangt:
//                mIvImg.setImageResource(R.drawable.warring_qhuangt);
//                break;
//            case R.string.warring_qlt:
//                mIvImg.setImageResource(R.drawable.warring_qlt);
//                break;
//            case R.string.warring_sbfw:
//                mIvImg.setImageResource(R.drawable.warring_sbfw);
//                break;
//            case R.string.warring_wcqg:
//                mIvImg.setImageResource(R.drawable.warring_wcqg);
//                break;
//            case R.string.warring_gdjc:
//                mIvImg.setImageResource(R.drawable.warring_gdjc);
//                break;
//            case R.string.warring_qbcqjc:
//                mIvImg.setImageResource(R.drawable.warring_qbcqjc);
//                break;
//            default:
//                mIvImg.setImageResource(R.drawable.bb);
//                break;
//        }
//        String contactsNum = (String) SharedPreferencesUtils.getParam(Name.CONTACTS_NUM, "");
//        String contactsName = (String) SharedPreferencesUtils.getParam(Name.CONTACTS_NAME, "");
        tvContent1.setText(UiUtil.getStringRes(R.string.warring_content1) /*+ contactsName + "-" + contactsNum*/);
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }
}
