示例#1
0
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.gmail_login_button:
        // mGoogleApiClient.connect();
        //                if (AppConstant.isNetworkAvailable(LoginActivity.this)) {
        if (AppConstant.isAndroid6()) {
          permissionHelper
              .setForceAccepting(false) // default is false. its here so you know that it exists.
              .request(SINGLE_PERMISSION);
        } else {
          signInGoogle();
        }
        //                } else {
        //                    Toast.makeText(LoginActivity.this,
        //                            "No Internet Connection Found.", Toast.LENGTH_LONG)
        //                            .show();
        //                }
        break;
      case R.id.btnFacebookLogin:
        LoginManager.getInstance()
            .logInWithReadPermissions(
                LoginActivity.this, Arrays.asList("public_profile", "user_friends", "email"));
        break;
      case R.id.btnLogin:
        logIn(1, v);
        break;

      case R.id.btnTryAgain:
        layoutCantConnect.setVisibility(View.GONE);
        if (AppConstant.isNetworkAvailable(LoginActivity.this)) {
          if (loginType == 1) {
            logIn(1, v);
          } else if (loginType == 2) {
            new LoginTask(loginId, loginName, loginEmail, loginImageUrl, 2).execute();
          } else if (loginType == 3) {
            new LoginTask(loginId, loginName, loginEmail, loginImageUrl, 3).execute();
          }
        } else {
          AppConstant.showNetworkError(LoginActivity.this);
        }
        break;

      case R.id.txtBottomSignup:
        Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
        startActivity(intent);
        break;

      case R.id.txtfrgtPassword:
        showForgotPasswordDialog(v);
        break;
      default:
        break;
    }
  }
 @Override
 public void onClick(View v) {
   if (v.getId() == R.id.single || v.getId() == R.id.multi) {
     isSingle = v.getId() == R.id.single;
     permissionHelper
         .setForceAccepting(false) // default is false. its here so you know that it exists.
         .request(isSingle ? SINGLE_PERMISSION : MULTI_PERMISSIONS);
   } else {
     permissionHelper.request(
         Manifest.permission.SYSTEM_ALERT_WINDOW); /*you can pass it along other permissions,
                    just make sure you override OnActivityResult so you can get a callback.
                    ignoring that will result to not be notified if the user enable/disable the permission*/
   }
 }