Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from steaks/fixOfflineScreen
Browse files Browse the repository at this point in the history
Attempt to fix offline screen
  • Loading branch information
Anu2g committed Jul 31, 2015
2 parents 3f4db9f + 815e405 commit 828aefd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/android/GooglePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class GooglePlus extends CordovaPlugin implements ConnectionCallbacks, On
public static final String ARGUMENT_WEB_KEY = "webApiKey";
public static final String ARGUMENT_SCOPE = "scope";

private String recoveringEmail;
private JSONObject recoveringResult;

// Wraps our service connection to Google Play services and provides access to the users sign in state and Google APIs
private GoogleApiClient mGoogleApiClient;
private String apiKey, webKey, scope;
Expand Down Expand Up @@ -123,6 +126,7 @@ private GoogleApiClient buildGoogleApiClient() {
@SuppressWarnings({ "unchecked", "rawtypes" })
private void resolveToken(final String email, final JSONObject result) {
final Context context = this.cordova.getActivity().getApplicationContext();
final GooglePlus self = this;

cordova.getThreadPool().execute(new Runnable() {
public void run() {
Expand Down Expand Up @@ -151,8 +155,10 @@ public void run() {
catch (UserRecoverableAuthException userAuthEx) {
// Start the user recoverable action using the intent returned by
// getIntent()
cordova.getActivity().startActivityForResult(userAuthEx.getIntent(),
Activity.RESULT_OK);
self.cordova.setActivityResultCallback(self);
self.recoveringEmail = email;
self.recoveringResult = result;
cordova.getActivity().startActivityForResult(userAuthEx.getIntent(), 10);
return;
}
catch (IOException e) {
Expand Down Expand Up @@ -263,7 +269,9 @@ public void onConnectionFailed(ConnectionResult result) {
@Override
public void onActivityResult(int requestCode, final int resultCode, final Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == Activity.RESULT_OK) {
if (mGoogleApiClient.isConnected() && resultCode == Activity.RESULT_OK) {
this.resolveToken(recoveringEmail, recoveringResult);
} else if (resultCode == Activity.RESULT_OK) {
mGoogleApiClient.connect();
} else {
this.savedCallbackContext.error("user cancelled");
Expand Down

0 comments on commit 828aefd

Please sign in to comment.