Search in sources :

Example 1 with FacebookAccountLoader

use of cl.smartcities.isci.transportinspector.gamification.socialAccount.facebook.FacebookAccountLoader in project androidApp by InspectorIncognito.

the class SocialAccountLoaderManager method loadAccount.

public void loadAccount(final LoaderInterface loaderInterface) {
    String accountType = preferences.getString(accountTypeKey, accountTypeKeyNull);
    CredentialsListener listener = new CredentialsListener() {

        @Override
        public void onSuccess(SocialMediaAccount account) {
            String nickname = TranSappApplication.getAppSharedPreferences().getString(SAVED_NICKNAME, "");
            loaderInterface.onLoad(account, nickname);
        }

        @Override
        public void onError(ServerStatusCode error) {
            loaderInterface.onError();
        }
    };
    switch(accountType) {
        case SocialMediaAccount.FACEBOOK_ACCOUNT:
            SocialAccountLoader facebookAccountLoader = new FacebookAccountLoader();
            facebookAccountLoader.load(listener);
            break;
        case SocialMediaAccount.GOOGLE_ACCOUNT:
            SocialAccountLoader googleAccountLoader = new GoogleAccountLoader();
            googleAccountLoader.load(listener);
            break;
        default:
            loaderInterface.onError();
    }
}
Also used : SocialMediaAccount(cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaAccount) FacebookAccountLoader(cl.smartcities.isci.transportinspector.gamification.socialAccount.facebook.FacebookAccountLoader) ServerStatusCode(cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode) GoogleAccountLoader(cl.smartcities.isci.transportinspector.gamification.socialAccount.google.GoogleAccountLoader) SocialAccountLoader(cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialAccountLoader) CredentialsListener(cl.smartcities.isci.transportinspector.gamification.socialAccount.CredentialsListener)

Aggregations

CredentialsListener (cl.smartcities.isci.transportinspector.gamification.socialAccount.CredentialsListener)1 SocialAccountLoader (cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialAccountLoader)1 SocialMediaAccount (cl.smartcities.isci.transportinspector.gamification.socialAccount.SocialMediaAccount)1 FacebookAccountLoader (cl.smartcities.isci.transportinspector.gamification.socialAccount.facebook.FacebookAccountLoader)1 GoogleAccountLoader (cl.smartcities.isci.transportinspector.gamification.socialAccount.google.GoogleAccountLoader)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)1