private void processUserInfo() { Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); mListener.onGSignInSuccess(person); }
@Override public void aoPrecisarCarregarMais() { if (mProxPagina != null) { mProgressBar.setVisibility(View.VISIBLE); Plus.PeopleApi.loadVisible(mGoogleApiClient, mProxPagina) .setResultCallback(ListaAmigosFragment.this); } } });
public void signOut() { if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); } } }
public void setProfileInfo() { //not sure if mGoogleapiClient.isConnect is appropriate... if (!mGoogleApiClient.isConnected() || Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) == null) { ((ImageView) getView().findViewById(R.id.avatar)) .setImageDrawable(null); ((TextView) getView().findViewById(R.id.display_name)) .setText(R.string.not_signed_in); } else { Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); if (currentPerson.hasImage()) { // Set the URL of the image that should be loaded into this view, and // specify the ImageLoader that will be used to make the request. ((NetworkImageView) getView().findViewById(R.id.avatar)).setImageUrl(currentPerson.getImage().getUrl(), mImageLoader); } if (currentPerson.hasDisplayName()) { ((TextView) getView().findViewById(R.id.display_name)) .setText(currentPerson.getDisplayName()); } } }
@Override protected void onResume() { super.onResume(); checkAndRequestPermission(AppPermissions.External_Storage_Permission); if (mPlusOneButton != null) { mPlusOneButton.initialize(APP_URL, 0); } MainApplication.activityResumed(); }
mPlusClient = new PlusClient.Builder(getContext(), this, this) .setScopes(mScopes) .build();
@Override public void onConnected(Bundle bundle) { if (mGridView.getAdapter() != null) { ((UploadedVideoAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } setProfileInfo(); mCallbacks.onConnected(Plus.AccountApi.getAccountName(mGoogleApiClient)); }
/** Sign out and disconnect from the APIs. */ public void signOut() { if (mState == STATE_DISCONNECTED) { // nothing to do debugLog("signOut: state was already DISCONNECTED, ignoring."); return; } // for the PlusClient, "signing out" means clearing the default account and // then disconnecting if (mPlusClient != null && mPlusClient.isConnected()) { debugLog("Clearing default account on PlusClient."); mPlusClient.clearDefaultAccount(); } // For the games client, signing out means calling signOut and disconnecting if (mGamesClient != null && mGamesClient.isConnected()) { debugLog("Signing out from GamesClient."); mGamesClient.signOut(); } // Ready to disconnect debugLog("Proceeding with disconnection."); killConnections(); }
void killConnections() { if (!checkState(TYPE_GAMEHELPER_BUG, "killConnections", "killConnections() should only " + "get called while connected or connecting.", STATE_CONNECTED, STATE_CONNECTING)) { return; } debugLog("killConnections: killing connections."); mConnectionResult = null; mSignInFailureReason = null; if (mGamesClient != null && mGamesClient.isConnected()) { debugLog("Disconnecting GamesClient."); mGamesClient.disconnect(); } if (mPlusClient != null && mPlusClient.isConnected()) { debugLog("Disconnecting PlusClient."); mPlusClient.disconnect(); } if (mAppStateClient != null && mAppStateClient.isConnected()) { debugLog("Disconnecting AppStateClient."); mAppStateClient.disconnect(); } mConnectedClients = CLIENT_NONE; debugLog("killConnections: all clients disconnected."); setState(STATE_DISCONNECTED); }
mConnectedClients |= CLIENT_GAMES; if (mPlusClient != null && mPlusClient.isConnected() && (0 == (mConnectedClients & CLIENT_PLUS))) { logWarn("PlusClient was already connected. Fixing.");
void connectCurrentClient() { if (mState == STATE_DISCONNECTED) { // we got disconnected during the connection process, so abort logWarn("GameHelper got disconnected during connection process. Aborting."); return; } if (!checkState(TYPE_GAMEHELPER_BUG, "connectCurrentClient", "connectCurrentClient " + "should only get called when connecting.", STATE_CONNECTING)) { return; } switch (mClientCurrentlyConnecting) { case CLIENT_GAMES: mGamesClient.connect(); break; case CLIENT_APPSTATE: mAppStateClient.connect(); break; case CLIENT_PLUS: mPlusClient.connect(); break; } }
public void signOut() { if (mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); mGoogleApiClient.connect(); } }
public void showPlusOneDialog() { final MaterialDialog dialog = new MaterialDialog.Builder(this) .customView(R.layout.dialog_plus_one, false) .canceledOnTouchOutside(true) .show(); View dialogView = dialog.getCustomView(); if (dialogView != null) { mPlusOneButton = (PlusOneButton) dialogView.findViewById(R.id.plus_one_button); mPlusOneButton.initialize(APP_URL, 0); } }
@Override protected String doInBackground(Void... params) { String token = null; try { String scope = String.format("oauth2:%s", Scopes.PROFILE); token = GoogleAuthUtil.getToken(LoginActivity.this, Plus.AccountApi.getAccountName(mGoogleApiClient), scope); } catch (IOException transientEx) { /* Network or server error */ Log.e(TAG, "Error authenticating with Google: " + transientEx); errorMessage = mStringNetworkError + transientEx.getMessage(); showAlertDialog(errorMessage); } catch (UserRecoverableAuthException e) { /* We probably need to ask for permissions, so start the intent if there is none pending */ Log.w(TAG, "Recoverable Google OAuth error: " + e.toString()); if (!mGoogleIntentInProgress) { mGoogleIntentInProgress = true; Intent recover = e.getIntent(); startActivityForResult(recover, RC_GOOGLE_LOGIN); } } catch (GoogleAuthException authEx) { /* The call is not ever expected to succeed assuming you have already verified that * Google Play services is installed. */ Log.e(TAG, "Error authenticating with Google: " + authEx.getMessage(), authEx); errorMessage = mStringAuthError + authEx.getMessage(); showAlertDialog(errorMessage); } return token; }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getActivity() instanceof GoogleApiProvider){ mGoogleApiClient = ((GoogleApiProvider)getActivity()).getGoogleApiClient(); } if (mPessoas == null || mPessoas.isEmpty()) { Plus.PeopleApi.loadVisible(mGoogleApiClient, null) .setResultCallback(this); mProgressBar.setVisibility(View.VISIBLE); } else { mAdapter = new PessoaAdapter(getActivity(), mPessoas); mListView.setAdapter(mAdapter); } } @Override
&& mPlusClient.isConnected()) {
/** Sign out and disconnect from the APIs. */ public void signOut() { if (!mGoogleApiClient.isConnected()) { // nothing to do debugLog("signOut: was already disconnected, ignoring."); return; } // for Plus, "signing out" means clearing the default account and // then disconnecting if (0 != (mRequestedClients & CLIENT_PLUS)) { debugLog("Clearing default account on PlusClient."); Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); } // For the games client, signing out means calling signOut and // disconnecting if (0 != (mRequestedClients & CLIENT_GAMES)) { debugLog("Signing out from the Google API Client."); Games.signOut(mGoogleApiClient); } // Ready to disconnect debugLog("Disconnecting client."); mConnectOnStart = false; mConnecting = false; mGoogleApiClient.disconnect(); }
@Override public View getView(final int position, View convertView, ViewGroup container) { if (convertView == null) { convertView = LayoutInflater.from(getActivity()).inflate( R.layout.list_item, container, false); } VideoData video = mVideos.get(position); ((TextView) convertView.findViewById(android.R.id.text1)) .setText(video.getTitle()); ((NetworkImageView) convertView.findViewById(R.id.thumbnail)).setImageUrl(video.getThumbUri(), mImageLoader); if (mGoogleApiClient.isConnected()) { ((PlusOneButton) convertView.findViewById(R.id.plus_button)) .initialize(video.getWatchUri(), null); } convertView.findViewById(R.id.main_target).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { mCallbacks.onVideoSelected(mVideos.get(position)); } }); return convertView; } }
/** Sign out and disconnect from the APIs. */ public void signOut() { if (!mGoogleApiClient.isConnected()) { // nothing to do debugLog("signOut: was already disconnected, ignoring."); return; } // for Plus, "signing out" means clearing the default account and // then disconnecting if (0 != (mRequestedClients & CLIENT_PLUS)) { debugLog("Clearing default account on PlusClient."); Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); } // For the games client, signing out means calling signOut and // disconnecting if (0 != (mRequestedClients & CLIENT_GAMES)) { debugLog("Signing out from the Google API Client."); Games.signOut(mGoogleApiClient); } // Ready to disconnect debugLog("Disconnecting client."); mConnectOnStart = false; mConnecting = false; mGoogleApiClient.disconnect(); }