示例#1
0
  // [START handleSignInResult]
  private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
      // Signed in successfully, show authenticated UI.
      GoogleSignInAccount acct = result.getSignInAccount();
      String emailPref = acct.getEmail();

      Log.d(TAG, " Handle signIn email of user" + emailPref);
      PrefUtils.setEmail(this, emailPref);
      // save Acct Name
      String namePref = acct.getDisplayName();
      PrefUtils.setPersonKey(this, namePref);

      Uri mPhoto = acct.getPhotoUrl();
      if (mPhoto != null) {

        //                personPhotoUrl = acct.getPhotoUrl().toString();
        personPhotoUrl = mPhoto.toString();
        Log.e(TAG, "Profile Image" + personPhotoUrl);
        personPhotoUrl =
            personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE;

        new LoadProfileImage().execute(personPhotoUrl);
      } else {
        Bitmap def = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);

        PrefUtils.setPhoto(this, def);

        Log.e(TAG, "Converted Launcher ICOn   " + def);

        Toast.makeText(this, "Profile Loaded, Registering User", Toast.LENGTH_SHORT).show();

        registerUser();
      }

    } else {
      // Signed out, show unauthenticated UI.
      Toast.makeText(
              this,
              "Ensure you are connected to a Network to be able to Sign In",
              Toast.LENGTH_SHORT)
          .show();
      //            signOutUser();
      RC_SIGN_IN++;
      //            btEnter.setVisibility(View.GONE);
      //            btnSignIn.setVisibility(View.VISIBLE);
      /*signOutUser();
      Toast.makeText(this, "An Error Occured, Check your Network Connection Settings",Toast.LENGTH_SHORT).show();
      btEnter.setVisibility(View.GONE);
      btnSignIn.setVisibility(View.VISIBLE);*/
      //            updateUI(false);
    }
  }
示例#2
0
    protected void onPostExecute(Bitmap result) {
      this.bitmap = result;

      Log.e(TAG, "ONPOSTEXECUTE result    " + result);
      bmImage.setImageBitmap(result);
      //            buttonContainer.setBackgroundResource(R.drawable.transparent_button);
      //            btnSignIn.setProgress(0);
      //            Toast.makeText(Login.this,"Profile Loaded", Toast.LENGTH_SHORT).show();
      if (result != null) {
        PrefUtils.setPhoto(Login.this, result);
        String m = PrefUtils.encodeTobase64(result);
        Log.e(TAG, "Encoded Profile image " + m);

        registerUser();
      } else {
        /*Bitmap def = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
        PrefUtils.setPhoto(context,def);

        Log.e(TAG, "Converted Launcher ICOn   " + def);
        Toast.makeText(Login.this, "Invalid image", Toast.LENGTH_SHORT).show();*/
      }

      //            registerUser();
    }