Search in sources :

Example 61 with Subscribe

use of com.squareup.otto.Subscribe in project zype-android by zype.

the class LoginActivity method handleConsumer.

@Subscribe
public void handleConsumer(ConsumerEvent event) {
    showProgress(false);
    if (event.getRequest() == WebApiManager.Request.CONSUMER_FORGOT_PASSWORD) {
        switchToResetPasswordCompletedScreen();
        return;
    }
    Consumer data = event.getEventData().getModelData();
    int subscriptionCount = data.getConsumerData().getSubscriptionCount();
    SettingsProvider.getInstance().saveSubscriptionCount(subscriptionCount);
    String consumerId = data.getConsumerData().getId();
    SettingsProvider.getInstance().saveConsumerId(consumerId);
    SettingsProvider.getInstance().setString(SettingsProvider.CONSUMER_EMAIL, data.getConsumerData().getEmail());
    AuthHelper.onLoginStateChanged();
    DataRepository.getInstance(this.getApplication()).loadVideoFavorites(success -> {
        DataRepository.getInstance(this.getApplication()).loadVideoEntitlements(success1 -> {
            Intent resultIntent = new Intent();
            if (getIntent().getExtras() != null) {
                resultIntent.putExtras(getIntent().getExtras());
            }
            setResult(RESULT_OK, resultIntent);
            finish();
        });
    });
}
Also used : Consumer(com.zype.android.webapi.model.consumers.Consumer) Intent(android.content.Intent) SpannableString(android.text.SpannableString) Subscribe(com.squareup.otto.Subscribe)

Example 62 with Subscribe

use of com.squareup.otto.Subscribe in project zype-android by zype.

the class LoginActivity method handleRetrieveAccessToken.

// //////////
// Subscriptions
// 
@Subscribe
public void handleRetrieveAccessToken(RetrieveAccessTokenEvent event) {
    Logger.d("handleRetrieveAccessToken");
    RetrieveAccessToken.RetrieveAccessTokenData data = event.getEventData().getModelData();
    SettingsProvider.getInstance().saveAccessToken(data.getAccessToken());
    SettingsProvider.getInstance().saveExpiresIn(data.getExpiresIn());
    SettingsProvider.getInstance().saveRefreshToken(data.getRefreshToken());
    SettingsProvider.getInstance().saveScope(data.getScope());
    SettingsProvider.getInstance().saveTokenType(data.getTokenType());
    AuthParamsBuilder authParamsBuilder = new AuthParamsBuilder();
    authParamsBuilder.addToken(data.getAccessToken());
    getApi().executeRequest(WebApiManager.Request.TOKEN_INFO, authParamsBuilder.build());
}
Also used : RetrieveAccessToken(com.zype.android.webapi.model.auth.RetrieveAccessToken) AuthParamsBuilder(com.zype.android.webapi.builder.AuthParamsBuilder) Subscribe(com.squareup.otto.Subscribe)

Example 63 with Subscribe

use of com.squareup.otto.Subscribe in project zype-android by zype.

the class LoginActivity method handleAccessTokenInfo.

@Subscribe
public void handleAccessTokenInfo(AccessTokenInfoEvent event) {
    Logger.d("handleAccessTokenInfo");
    showProgress(false);
    TokenInfo data = event.getEventData().getModelData();
    SettingsProvider.getInstance().saveAccessTokenApplication(data.getApplicationData());
    SettingsProvider.getInstance().saveAccessTokenCreatedAt(data.getCreatedAt());
    SettingsProvider.getInstance().saveAccessTokenExpiration(data.getExpiresInSeconds());
    SettingsProvider.getInstance().saveAccessTokenResourceOwnerId(data.getResourceOwnerId());
    SettingsProvider.getInstance().saveAccessTokenScopes(data.getScopes());
    ConsumerParamsBuilder builder = new ConsumerParamsBuilder().addAccessToken();
    getApi().executeRequest(WebApiManager.Request.CONSUMER_GET, builder.build());
}
Also used : ConsumerParamsBuilder(com.zype.android.webapi.builder.ConsumerParamsBuilder) TokenInfo(com.zype.android.webapi.model.auth.TokenInfo) Subscribe(com.squareup.otto.Subscribe)

Example 64 with Subscribe

use of com.squareup.otto.Subscribe in project zype-android by zype.

the class LoginActivity method handleDevicePin.

@Subscribe
public void handleDevicePin(DevicePinEvent event) {
    DevicePinData data = event.getEventData().getModelData().data;
    pin = data.pin;
    if (data.linked) {
        getAccessTokenWithPin();
    } else {
        bindViews();
    }
}
Also used : DevicePinData(com.zype.android.webapi.model.linking.DevicePinData) Subscribe(com.squareup.otto.Subscribe)

Example 65 with Subscribe

use of com.squareup.otto.Subscribe in project zype-android by zype.

the class ConsumerActivity method handleConsumer.

// //////////
// Event bus listeners
// 
@Subscribe
public void handleConsumer(ConsumerEvent event) {
    Logger.d("handleConsumer()");
    hideProgress();
    ConsumerData data = event.getEventData().getModelData().getConsumerData();
    SettingsProvider.getInstance().saveSubscriptionCount(data.getSubscriptionCount());
    SettingsProvider.getInstance().setString(SettingsProvider.CONSUMER_EMAIL, consumer.email);
    SettingsProvider.getInstance().setString(SettingsProvider.CONSUMER_PASSWORD, consumer.password);
    Bundle extras = new Bundle();
    extras.putBoolean(LoginActivity.PARAMETERS_FORCE_LOGIN, true);
    NavigationHelper.getInstance(ConsumerActivity.this).switchToLoginScreen(ConsumerActivity.this, extras);
}
Also used : ConsumerData(com.zype.android.webapi.model.consumers.ConsumerData) Bundle(android.os.Bundle) Subscribe(com.squareup.otto.Subscribe)

Aggregations

Subscribe (com.squareup.otto.Subscribe)86 Test (org.junit.Test)28 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)27 RawTodoList (com.armueller.fluxytodo.data.RawTodoList)13 ArrayList (java.util.ArrayList)12 TodoAction (com.armueller.fluxytodo.actions.TodoAction)9 VideoData (com.zype.android.webapi.model.video.VideoData)8 DataBundle (com.armueller.fluxytodo.actions.DataBundle)7 File (com.zype.android.webapi.model.player.File)7 Intent (android.content.Intent)6 FilteredTodoList (com.armueller.fluxytodo.data.FilteredTodoList)6 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)6 Bundle (android.os.Bundle)5 Video (com.zype.android.Db.Entity.Video)5 Consumer (com.zype.android.webapi.model.consumers.Consumer)5 IOException (java.io.IOException)5 Context (android.content.Context)4 ConnectivityManager (android.net.ConnectivityManager)4 NetworkInfo (android.net.NetworkInfo)4 Dialog (android.app.Dialog)3