package com.danding.yang800;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.danding.yang800.Presenter.CheckPhoneActivityPresenter;
import com.danding.yang800.Presenter.CheckTakePassActivityPresenter;
import com.danding.yang800.Util.StatusColorUtil;
import com.danding.yang800.View.NetworkProgressDialog;
import com.yanzhenjie.sofia.Sofia;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CheckTakePassActivity extends BaseActivity {
    @BindView(R.id.checktakePasee_saveTv)
    TextView checktakePasee_saveTv;
    @BindView(R.id.checkTakePass_backTv)
    TextView checkTakePass_backTv;
    @BindView(R.id.checkTakePass_passTv)
    EditText checkTakePass_passTv;
    private NetworkProgressDialog pd;
    CheckTakePassActivityPresenter presenter;
    SharedPreferences sp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        int type = StatusColorUtil.StatusBarLightMode(this);
//        if (type > 0) {
//            StatusColorUtil.setStatusBarColor(this, R.color.white);
//            StatusColorUtil.StatusBarLightMode(this, type);
//        }
        setContentView(R.layout.activity_check_take_pass);
        Sofia.with(this).statusBarDarkFont().statusBarBackground(ContextCompat.getColor(this, R.color.white));
        sp = getSharedPreferences("variable", Context.MODE_PRIVATE);
        ButterKnife.bind(this);
        presenter = new CheckTakePassActivityPresenter(this);
    }

    @OnClick({R.id.checktakePasee_saveTv, R.id.checkTakePass_backTv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.checktakePasee_saveTv:
                presenter.updateInfo(sp.getInt("userId", 0)+"", checkTakePass_passTv.getText().toString().trim());
                break;
            case R.id.checkTakePass_backTv:
                finish();
                break;
        }

    }

    public void initDialog() {
        if (pd == null) {
            pd = NetworkProgressDialog.createDialog(this);
            if (!pd.isShowing()) {
                pd.show();
            }
        }
    }

    public void dismissDialog() {
        if (pd != null) {
            pd.dismiss();
            pd = null;
            NetworkProgressDialog.clear();
        }
    }

    public void success() {
        startActivity(ChangePhoneActivity.class);
        finish();
    }
}
