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
}
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());
}
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());
}
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();
}
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());
}
}
}
Aggregations