Created
March 20, 2017 02:03
-
-
Save Majirefy/07c61350e4093dab401e007b9f786576 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class PlayServiceListener : GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { | |
override fun onConnected(bundle: Bundle?) { | |
Toast.makeText(context, R.string.login_succeed, Toast.LENGTH_SHORT).show() | |
GameManager.listener?.loadHighScore() | |
} | |
override fun onConnectionSuspended(i: Int) { | |
// Attempt to reconnect | |
mGoogleApiClient?.connect() | |
} | |
override fun onConnectionFailed(connectionResult: ConnectionResult) { | |
if (mResolvingError) { | |
// Already attempting to resolve an error. | |
return | |
} else if (connectionResult.hasResolution()) { | |
try { | |
mResolvingError = true | |
connectionResult.startResolutionForResult(context as Activity, REQUEST_RESOLVE_ERROR) | |
} catch (e: IntentSender.SendIntentException) { | |
// There was an error with the resolution intent. Try again. | |
mGoogleApiClient?.connect() | |
} | |
} else { | |
// Show dialog using GoogleApiAvailability.getErrorDialog() | |
Toast.makeText(context, R.string.login_failed, Toast.LENGTH_SHORT).show() | |
mResolvingError = true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment