Search in sources :

Example 36 with Subscribe

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

the class MarketplaceGateway method handleError.

@Subscribe
public void handleError(ErrorEvent event) {
    if (event.getEventData() == WebApiManager.Request.MARKETPLACE_CONNECT) {
        Logger.e("handleError(): Marketplace connect");
        RetrofitError error = event.getError();
        if (error != null) {
            if (subscriptionVerified != null) {
                subscriptionVerified.setValue(false);
            }
            if (playlistPurchaseVerified != null) {
                playlistPurchaseVerified.setValue(false);
            }
        }
    }
// TODO: Add retrieve plan error handling
}
Also used : RetrofitError(retrofit.RetrofitError) Subscribe(com.squareup.otto.Subscribe)

Example 37 with Subscribe

use of com.squareup.otto.Subscribe in project otto by square.

the class OutsideEventBusTest method anonymous.

/*
   * If you do this test from common.eventbus.BusTest, it doesn't actually test the behavior.
   * That is, even if exactly the same method works from inside the common.eventbus package tests,
   * it can fail here.
   */
@Test
public void anonymous() {
    final AtomicReference<String> holder = new AtomicReference<String>();
    final AtomicInteger deliveries = new AtomicInteger();
    Bus bus = new Bus(ThreadEnforcer.ANY);
    bus.register(new Object() {

        @Subscribe
        public void accept(String str) {
            holder.set(str);
            deliveries.incrementAndGet();
        }
    });
    String EVENT = "Hello!";
    bus.post(EVENT);
    assertEquals("Only one event should be delivered.", 1, deliveries.get());
    assertEquals("Correct string should be delivered.", EVENT, holder.get());
}
Also used : Bus(com.squareup.otto.Bus) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicReference(java.util.concurrent.atomic.AtomicReference) Subscribe(com.squareup.otto.Subscribe) Test(org.junit.Test)

Example 38 with Subscribe

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

the class LoginActivity method handleRetrieveAccessToken.

@Subscribe
public void handleRetrieveAccessToken(RetrieveAccessTokenEvent event) {
    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());
    Logger.d("handleRetrieveAccessToken");
    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 39 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) {
    Consumer data = event.getEventData().getModelData();
    int subscriptionCount = data.getConsumerData().getSubscriptionCount();
    SettingsProvider.getInstance().saveSubscriptionCount(subscriptionCount);
    String consumerId = data.getConsumerData().getId();
    SettingsProvider.getInstance().saveConsumerId(consumerId);
    showProgress(false);
    setResult(RESULT_OK);
    finish();
}
Also used : Consumer(com.zype.android.webapi.model.consumers.Consumer) Subscribe(com.squareup.otto.Subscribe)

Example 40 with Subscribe

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

the class MyLibraryFragment method handleVideoEntitlements.

// ///////////
// Subscriptions
// 
@Subscribe
public void handleVideoEntitlements(VideoEntitlementsEvent event) {
    VideoEntitlements data = event.getEventData().getModelData();
    Logger.d("handleVideoEntitlements(): size=" + data.videoEntitlements.size());
    for (VideoEntitlementData item : data.videoEntitlements) {
        videoEntitlements.put(item.videoId, item);
    }
    if (Pagination.hasNextPage(data.pagination) && !data.videoEntitlements.isEmpty()) {
        requestVideoEntitlements(Pagination.getNextPage(data.pagination));
    } else {
        // Clear entitlement flag in all existing videos
        VideoHelper.setEntitlement(getActivity().getContentResolver(), null, false, "");
        // Load videos with entitlements
        for (String videoId : videoEntitlements.keySet()) {
            VideoParamsBuilder builder = new VideoParamsBuilder().addVideoId(videoId);
            getApi().executeRequest(WebApiManager.Request.VIDEO_LATEST_GET, builder.build());
        }
    }
}
Also used : VideoParamsBuilder(com.zype.android.webapi.builder.VideoParamsBuilder) VideoEntitlementData(com.zype.android.webapi.model.entitlements.VideoEntitlementData) VideoEntitlements(com.zype.android.webapi.model.entitlements.VideoEntitlements) Subscribe(com.squareup.otto.Subscribe)

Aggregations

Subscribe (com.squareup.otto.Subscribe)85 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