@Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.register:
        if (operation == UserOperation.LOGIN) {
          if (TextUtils.isEmpty(userNameInput.getText())) {
            userNameInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入用户名", Toast.LENGTH_SHORT).show();
            return;
          }
          if (TextUtils.isEmpty(userPasswordInput.getText())) {
            userPasswordInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入密码", Toast.LENGTH_SHORT).show();
            return;
          }

          userProxy.setOnLoginListener(this);
          Log.i(TAG, "login begin....");
          // progressbar.setVisibility(View.VISIBLE);
          userProxy.login(
              userNameInput.getText().toString().trim(),
              userPasswordInput.getText().toString().trim());

        } else if (operation == UserOperation.REGISTER) { // 注册
          if (TextUtils.isEmpty(userNameInput.getText())) {
            userNameInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入用户名", Toast.LENGTH_SHORT).show();
            return;
          }
          if (TextUtils.isEmpty(userPasswordInput.getText())) {
            userPasswordInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入密码", Toast.LENGTH_SHORT).show();
            return;
          }
          if (TextUtils.isEmpty(userEmailInput.getText())) {
            userEmailInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入邮箱地址", Toast.LENGTH_SHORT).show();
            return;
          }
          if (!StringUtils.isValidEmail(userEmailInput.getText())) {
            userEmailInput.setShakeAnimation();
            Toast.makeText(mContext, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
            return;
          }
          if (TextUtils.isEmpty(userSchoolInput.getText())) {
            userSchoolInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入学校全称", Toast.LENGTH_SHORT).show();
            return;
          }

          userProxy.setOnSignUpListener(this);
          Log.i(TAG, "register begin....");
          //  progressbar.setVisibility(View.VISIBLE);
          userProxy.signUp(
              userNameInput.getText().toString().trim(),
              userPasswordInput.getText().toString().trim(),
              userEmailInput.getText().toString().trim(),
              userSchoolInput.getText().toString().trim());

        } else {
          if (TextUtils.isEmpty(userEmailInput.getText())) {
            userEmailInput.setShakeAnimation();
            Toast.makeText(mContext, "请输入邮箱地址", Toast.LENGTH_SHORT).show();
            return;
          }
          if (!StringUtils.isValidEmail(userEmailInput.getText())) {
            userEmailInput.setShakeAnimation();
            Toast.makeText(mContext, "邮箱格式不正确", Toast.LENGTH_SHORT).show();
            return;
          }
          userProxy.setOnResetPasswordListener(this);
          Log.i(TAG, "reset password begin....");
          //  progressbar.setVisibility(View.VISIBLE);
          userProxy.resetPassword(userEmailInput.getText().toString().trim());
        }
        break;
      case R.id.login_menu:
        operation = UserOperation.LOGIN;
        updateLayout(operation);
        break;
      case R.id.register_menu:
        operation = UserOperation.REGISTER;
        updateLayout(operation);
        break;
      case R.id.reset_password_menu:
        operation = UserOperation.RESET_PASSWORD;
        updateLayout(operation);
        break;
      default:
        break;
    }
  }
  private void updateLayout(UserOperation op) {
    if (op == UserOperation.LOGIN) {
      loginTitle.setTextColor(Color.parseColor("#D95555"));
      loginTitle.setBackgroundResource(R.mipmap.bg_login_tab);
      loginTitle.setPadding(16, 16, 16, 16);
      loginTitle.setGravity(Gravity.CENTER);

      registerTitle.setTextColor(Color.parseColor("#888888"));
      registerTitle.setBackgroundDrawable(null);
      registerTitle.setPadding(16, 16, 16, 16);
      registerTitle.setGravity(Gravity.CENTER);

      resetPassword.setTextColor(Color.parseColor("#888888"));
      resetPassword.setBackgroundDrawable(null);
      resetPassword.setPadding(16, 16, 16, 16);
      resetPassword.setGravity(Gravity.CENTER);

      userNameInput.setVisibility(View.VISIBLE);
      userPasswordInput.setVisibility(View.VISIBLE);
      userSchoolInput.setVisibility(View.GONE);
      userEmailInput.setVisibility(View.GONE);
      registerButton.setText("登录");
    } else if (op == UserOperation.REGISTER) {
      loginTitle.setTextColor(Color.parseColor("#888888"));
      loginTitle.setBackgroundDrawable(null);
      loginTitle.setPadding(16, 16, 16, 16);
      loginTitle.setGravity(Gravity.CENTER);

      registerTitle.setTextColor(Color.parseColor("#D95555"));
      registerTitle.setBackgroundResource(R.mipmap.bg_login_tab);
      registerTitle.setPadding(16, 16, 16, 16);
      registerTitle.setGravity(Gravity.CENTER);

      resetPassword.setTextColor(Color.parseColor("#888888"));
      resetPassword.setBackgroundDrawable(null);
      resetPassword.setPadding(16, 16, 16, 16);
      resetPassword.setGravity(Gravity.CENTER);

      userNameInput.setVisibility(View.VISIBLE);
      userPasswordInput.setVisibility(View.VISIBLE);
      userEmailInput.setVisibility(View.VISIBLE);
      userSchoolInput.setVisibility(View.VISIBLE);
      registerButton.setText("注册");
    } else {
      loginTitle.setTextColor(Color.parseColor("#888888"));
      loginTitle.setBackgroundDrawable(null);
      loginTitle.setPadding(16, 16, 16, 16);
      loginTitle.setGravity(Gravity.CENTER);

      registerTitle.setTextColor(Color.parseColor("#888888"));
      registerTitle.setBackgroundDrawable(null);
      registerTitle.setPadding(16, 16, 16, 16);
      registerTitle.setGravity(Gravity.CENTER);

      resetPassword.setTextColor(Color.parseColor("#D95555"));
      resetPassword.setBackgroundResource(R.mipmap.bg_login_tab);
      resetPassword.setPadding(16, 16, 16, 16);
      resetPassword.setGravity(Gravity.CENTER);

      userNameInput.setVisibility(View.GONE);
      userPasswordInput.setVisibility(View.GONE);
      userEmailInput.setVisibility(View.VISIBLE);
      registerButton.setText("找回密码");
    }
  }