<commit_before>package com.techshino.eyekeydemo.activity;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

import com.techshino.eyekeydemo.R;
import com.techshino.eyekeydemo.utils.CustomUtil;
import com.techshino.eyekeydemo.utils.Logs;
import com.techshino.eyekeydemo.utils.SnackBarUtils;
import com.techshino.eyekeydemo.utils.StringUtils;
import com.techshino.eyekeydemo.utils.ToastUtils;
import com.techshino.eyekeysdk.api.CheckAPI;
import com.techshino.eyekeysdk.conn.Constant;
import com.techshino.eyekeysdk.entity.PeopleDelete;
import com.techshino.eyekeysdk.entity.PeopleGet;

import butterknife.Bind;
import butterknife.OnClick;
import butterknife.OnTextChanged;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by wangzhi on 2015/12/25.
 * <p>
 * 首页
 */
public class IndexActivity extends BaseAppcompatActivity {

  private static final String TAG = IndexActivity.class.getSimpleName();

  private static final String OFFCIAL_WEB_URL = "http://www.eyekey.com";

  private static final int ACTION_VERIFY = 1;
  private static final int ACTION_REGISTER = 2;
  @Bind(R.id.toolbar)
  Toolbar mToolbar;
  @Bind(R.id.toolbarTitle)
  TextView mTitleText;
  @Bind(R.id.container)
  CoordinatorLayout mContainer;
  @Bind(R.id.nameEdit)
  EditText mNameEdit;
  ProgressDialog mProgressDialog;
  private int mAction;
  private int mCameraId = 1;
  private String mName;

  @Override
  public void initData() {
    mProgressDialog = new ProgressDialog(this);
    mTitleText.setText(R.string.app_title);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle("");
  }

  @Override
  public int getLayoutId() {
    return R.layout.activity_index;
  }

  @OnTextChanged(callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED, value = R.id.nameEdit)
  void etNameEdit(Editable editable) {
    mName = editable.toString();
  }

  /**
   * 验证
   */
  @OnClick(R.id.takeImg)
  void verifyIconClick() {
    mAction = ACTION_VERIFY;
    peopleGet();
  }

  /**
   * 注册
   */
  @OnClick(R.id.registerIcon)
  void registerIconClick() {
    mAction = ACTION_REGISTER;
    peopleGet();
  }

  /**
   * 重置
   */
  @OnClick(R.id.resetIcon)
  void resetIconClick() {
    if (StringUtils.isBlank(mName)) {
      ToastUtils.show(this, R.string.text_name_not_empty);
      return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(CustomUtil.getString(this, R.string.text_delete_confirm))
        .setPositiveButton(R.string.text_confirm, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            peopleDelete();
          }
        })
        .setNegativeButton(R.string.text_cancel, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        }).show();
  }

  /**
   * 官网
   */
  @OnClick(R.id.offcialIcon)
  void offcialIconClick() {
    Uri uri = Uri.parse(OFFCIAL_WEB_URL);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    startActivity(intent);
  }

  /**
   * 切换摄像头
   */
  @OnClick(R.id.changeCamera)
  void changeCameraClick() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    if (mCameraId == 0) {
      builder.setMessage(R.string.text_is_change_front_preview);
    } else {
      builder.setMessage(R.string.text_is_change_back_preview);
    }
    builder
        .setPositiveButton(R.string.text_confirm, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            changeCamera();
            dialog.dismiss();
          }
        })
        .setNegativeButton(R.string.text_cancel, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        })
        .show();
  }

  private void peopleDelete() {
    mProgressDialog.setMessage(CustomUtil.getString(IndexActivity.this, R.string.text_deleting));
    mProgressDialog.show();
    Call<PeopleDelete> call = CheckAPI.peopleDeleteByName(mName);
    call.enqueue(new Callback<PeopleDelete>() {

      public void onFinish() {
        mProgressDialog.dismiss();
      }

      @Override
      public void onResponse(Call<PeopleDelete> call, Response<PeopleDelete> response) {
        onFinish();
        handleDelete(response.body());
      }

      @Override
      public void onFailure(Call<PeopleDelete> call, Throwable t) {
        onFinish();
        ToastUtils.show(IndexActivity.this, R.string.toast_network_error);
      }
    });<commit_msg>use lambda<commit_after>package com.techshino.eyekeydemo.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

import com.techshino.eyekeydemo.R;
import com.techshino.eyekeydemo.utils.CustomUtil;
import com.techshino.eyekeydemo.utils.Logs;
import com.techshino.eyekeydemo.utils.SnackBarUtils;
import com.techshino.eyekeydemo.utils.StringUtils;
import com.techshino.eyekeydemo.utils.ToastUtils;
import com.techshino.eyekeysdk.api.CheckAPI;
import com.techshino.eyekeysdk.conn.Constant;
import com.techshino.eyekeysdk.entity.PeopleDelete;
import com.techshino.eyekeysdk.entity.PeopleGet;

import butterknife.Bind;
import butterknife.OnClick;
import butterknife.OnTextChanged;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by wangzhi on 2015/12/25.
 * <p>
 * 首页
 */
public class IndexActivity extends BaseAppcompatActivity {

  private static final String TAG = IndexActivity.class.getSimpleName();

  private static final String OFFCIAL_WEB_URL = "http://www.eyekey.com";

  private static final int ACTION_VERIFY = 1;
  private static final int ACTION_REGISTER = 2;
  @Bind(R.id.toolbar)
  Toolbar mToolbar;
  @Bind(R.id.toolbarTitle)
  TextView mTitleText;
  @Bind(R.id.container)
  CoordinatorLayout mContainer;
  @Bind(R.id.nameEdit)
  EditText mNameEdit;
  ProgressDialog mProgressDialog;
  private int mAction;
  private int mCameraId = 1;
  private String mName;

  @Override
  public void initData() {
    mProgressDialog = new ProgressDialog(this);
    mTitleText.setText(R.string.app_title);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle("");
  }

  @Override
  public int getLayoutId() {
    return R.layout.activity_index;
  }

  @OnTextChanged(callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED, value = R.id.nameEdit)
  void etNameEdit(Editable editable) {
    mName = editable.toString();
  }

  /**
   * 验证
   */
  @OnClick(R.id.takeImg)
  void verifyIconClick() {
    mAction = ACTION_VERIFY;
    peopleGet();
  }

  /**
   * 注册
   */
  @OnClick(R.id.registerIcon)
  void registerIconClick() {
    mAction = ACTION_REGISTER;
    peopleGet();
  }

  /**
   * 重置
   */
  @OnClick(R.id.resetIcon)
  void resetIconClick() {
    if (StringUtils.isBlank(mName)) {
      ToastUtils.show(this, R.string.text_name_not_empty);
      return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(CustomUtil.getString(this, R.string.text_delete_confirm))
        .setPositiveButton(R.string.text_confirm, (dialog, which) -> {
          dialog.dismiss();
          peopleDelete();
        })
        .setNegativeButton(R.string.text_cancel, (dialog, which) -> dialog.dismiss()).show();
  }

  /**
   * 官网
   */
  @OnClick(R.id.offcialIcon)
  void offcialIconClick() {
    Uri uri = Uri.parse(OFFCIAL_WEB_URL);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    startActivity(intent);
  }

  /**
   * 切换摄像头
   */
  @OnClick(R.id.changeCamera)
  void changeCameraClick() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    if (mCameraId == 0) {
      builder.setMessage(R.string.text_is_change_front_preview);
    } else {
      builder.setMessage(R.string.text_is_change_back_preview);
    }
    builder
        .setPositiveButton(R.string.text_confirm, (dialog, which) -> {
          changeCamera();
          dialog.dismiss();
        })
        .setNegativeButton(R.string.text_cancel, (dialog, which) -> dialog.dismiss())
        .show();
  }

  private void peopleDelete() {
    mProgressDialog.setMessage(CustomUtil.getString(IndexActivity.this, R.string.text_deleting));
    mProgressDialog.show();
    Call<PeopleDelete> call = CheckAPI.peopleDeleteByName(mName);
    call.enqueue(new Callback<PeopleDelete>() {

      public void onFinish() {
        mProgressDialog.dismiss();
      }

      @Override
      public void onResponse(Call<PeopleDelete> call, Response<PeopleDelete> response) {
        onFinish();
        handleDelete(response.body());
      }

      @Override
      public void onFailure(Call<PeopleDelete> call, Throwable t) {
        onFinish();
        ToastUtils.show(IndexActivity.this, R.string.toast_network_error);
      }
    });
{'fraction_non_alphanumeric': 0.11315817020831152, 'fraction_numerical': 0.0035590913849052656, 'mean_word_length': 3.4728464419475658, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '259462', 'n_tokens_mistral': 3123, 'n_tokens_neox': 3036, 'n_words': 526}