use of cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode in project androidApp by InspectorIncognito.
the class FacebookAccountLoginner method login.
@Override
public void login() {
Log.d(TAG, "Login Facebook Account");
final AccessTokenTracker tracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
Log.d(TAG, "onCurrentAccessTokenChanged");
this.stopTracking();
loginFragment.startLoading();
dataManager.getCredentials(new CredentialsListener() {
@Override
public void onSuccess(SocialMediaAccount account) {
loginFragment.stopLoading();
listener.onSuccess(account);
}
@Override
public void onError(ServerStatusCode error) {
loginFragment.stopLoading();
listener.onError(error);
}
});
}
};
Log.d(TAG, "Starting tracker");
tracker.startTracking();
LoginManager.getInstance().logInWithReadPermissions(loginFragment, Arrays.asList("email", "public_profile"));
TranSappApplication.getAppSharedPreferences().edit().putBoolean(TranSappApplication.getAppContext().getString(R.string.facebook_log_in), true).apply();
}
use of cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode in project androidApp by InspectorIncognito.
the class GoogleAccountLoader method load.
@Override
public void load(final CredentialsListener listener) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken(TranSappApplication.getAppContext().getString(R.string.server_client_id)).build();
final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(TranSappApplication.getAppContext()).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (pendingResult.isDone()) {
loadDataFromSignInResult(pendingResult.get(), listener, mGoogleApiClient);
} else {
pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(@NonNull GoogleSignInResult result) {
if (result.isSuccess()) {
loadDataFromSignInResult(result, listener, mGoogleApiClient);
} else {
listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
}
}
}, 5000, TimeUnit.MILLISECONDS);
}
}
@Override
public void onConnectionSuspended(int i) {
listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
}
});
mGoogleApiClient.connect();
}
use of cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode in project androidApp by InspectorIncognito.
the class GoogleAccountLoginner method handleSignInResult.
private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
GoogleDataManager manager = new GoogleDataManager();
manager.getCredentials(listener, acct, mGoogleApiClient);
} else {
listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
mGoogleApiClient.stopAutoManage(compatActivity.getActivity());
mGoogleApiClient.disconnect();
}
}
Aggregations