package com.oo.eye.activity;

import android.view.View;
import android.widget.TextView;

import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.app.baselibrary.commonUtil.ToastUtil;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.seex.sys_state.widget.StateView;

import butterknife.BindView;

/**
 */

public class EyeSettingActivity extends BaseActivity{

	@BindView(R2.id.state_view)
	StateView mStateView;

	@BindView(R2.id.tv_eye_setting_normal)
	TextView normalText;

	@BindView(R2.id.tv_eye_setting_decimals)
	TextView decimalsText;

	private int selectId;

	@Override
	protected int getLayoutId() {
		return R.layout.activity_eye_setting;
	}

	protected void onResume() {
		super.onResume();
		mStateView.registStateListener();
	}


	@Override
	protected void onPause() {
		super.onPause();
		mStateView.unRegistStateListener();
	}

	@Override
	protected void init() {
		selectId = PreferencesUtils.getInt( EyeConfig.EYE_SETTING_KEY,selectId);
		normalText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if(hasFocus){
					normalText.setTextColor(getResources().getColor(R.color.e_test_color));
				}else{
					normalText.setTextColor(getResources().getColor(R.color.white));
				}
			}
		});
		normalText.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				selectId = 0;
				PreferencesUtils.putInt( EyeConfig.EYE_SETTING_KEY,selectId);
				ToastUtil.showLongMessage("选择5分法成功");
			}
		});
		decimalsText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if(hasFocus){
					decimalsText.setTextColor(getResources().getColor(R.color.e_test_color));
					selectId = 1;
				}else{
					decimalsText.setTextColor(getResources().getColor(R.color.white));
				}
			}
		});
		decimalsText.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				selectId = 1;
				PreferencesUtils.putInt( EyeConfig.EYE_SETTING_KEY,selectId);
				ToastUtil.showLongMessage("选择小数法成功");
			}
		});
		if(selectId == 1){
			decimalsText.requestFocus();
		}
	}

}
