package com.oo.eye.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.app.baselibrary.commonUtil.DensityUtil;
import com.oo.eye.R;

import java.util.Date;

/**
 * Date : 2018/9/13.
 * Author:  cxh
 */

public class BeforeTestDialog extends Dialog {
    private RelativeLayout mLlBeforeEyeStart1;
    private LinearLayout mLlBeforeEyePrepare1;
    private TextView mTextView;
    private BeforeTestListener myListener;

    public BeforeTestDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public BeforeTestDialog(@NonNull Context context) {
        super(context);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_before_eye_test);
        initView();
    }

    private void initView() {
        RelativeLayout rootView = (RelativeLayout) findViewById(R.id.root_view);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DensityUtil.getScreenWidth(), DensityUtil.getScreenHeight());
        rootView.setLayoutParams(params);
        mLlBeforeEyeStart1= (RelativeLayout) findViewById(R.id.ll_before_eye_start1);
        mLlBeforeEyePrepare1= (LinearLayout) findViewById(R.id.ll_before_eye_prepare1);
        mTextView= (TextView) findViewById(R.id.tv_eye_test_start1);
        mTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(myListener != null){
                    myListener.onClick();
                }
                mLlBeforeEyeStart1.setVisibility(View.GONE);
                mLlBeforeEyePrepare1.setVisibility(View.VISIBLE);
                dismiss();
            }
        });
    }
    public static class Builder {
        private BeforeTestDialog mDialog;

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

        public BeforeTestDialog.Builder setOnClickListener(BeforeTestListener listener) {
            mDialog.myListener = listener;
            return this;
        }

        public BeforeTestDialog create() {
            return mDialog;
        }

    }
    public interface BeforeTestListener {
        void onClick();
    }
}
