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