package com.oo.eye.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.oo.eye.R;

/**
 * Date : 2018/5/2.
 * Author:  cxh
 * 测试完成后
 */

public class AfterTestDialog extends Dialog implements View.OnClickListener {

    private SimpleDraweeView mHead_iv;
    private TextView mUsername_tv;
    private TextView mLeftEye;
    private TextView mRightEye;
    private TextView mTestTime;
    private TextView mNextName;
    private static TextView mPlan_start_train;
    private TextView mStart_train_later;
    private TextView mGiveUp2;

    private String userName;
    private String lefteye;
    private String righteye;
    private String trainTime;
    private AfterTestListener myListener;

    public AfterTestDialog(Context context, int themeResId) {
        super(context, themeResId);

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
        setContentView(R.layout.dialog_after_eye_test);
        initView();
        setClickListener();
    }


    private void initView() {
        mUsername_tv = (TextView) findViewById(R.id.tv_after_name);
        mNextName= (TextView) findViewById(R.id.tv_nest_name);
        mLeftEye = (TextView) findViewById(R.id.tv_after_result_left);
        mRightEye = (TextView) findViewById(R.id.tv_after_result_right);
        mTestTime = (TextView) findViewById(R.id.tv_after_time);
        mPlan_start_train = (TextView) findViewById(R.id.tv_after_save);
        mStart_train_later = (TextView) findViewById(R.id.tv_after_give_up);
        mGiveUp2 = (TextView) findViewById(R.id.tv_after_give2);

        mUsername_tv.setText(userName);
        mLeftEye.setText(lefteye);
        mRightEye.setText(righteye);
        mTestTime.setText(trainTime);
    }

    private void setClickListener() {
        mPlan_start_train.setOnClickListener(this);
        mStart_train_later.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        //继续测试
        if (v.getId() == R.id.tv_after_save) {
            if (myListener != null) {
                myListener.onAfterTestListener(v);
                dismiss();
            }
        } else {
            dismiss();
        }
    }

    public interface AfterTestListener {
        void onAfterTestListener(View view);
    }

    public static class Builder {
        private AfterTestDialog mDialog;

        public Builder(Context context, int themeResId) {
            mDialog = new AfterTestDialog(context, themeResId);
        }

        public Builder setUserName(String userName) {
            mDialog.userName = userName;
            return this;
        }

        public Builder setLeftEye(String trainPlan) {
            mDialog.lefteye = trainPlan;
            return this;
        }

        public Builder setRightEye(String trainCount) {
            mDialog.righteye = trainCount;
            return this;
        }

        public Builder setTrainTime(String trainTime) {
            mDialog.trainTime = trainTime;
            return this;
        }

        public Builder setOnLittleHelperListener(AfterTestListener listener) {
            mDialog.myListener = listener;
            return this;
        }

        public AfterTestDialog create() {
            return mDialog;
        }

    }

    public static TextView getCountDownTtext() {
        return mPlan_start_train;
    }
}
