use of com.squareup.otto.Subscribe in project android-store by soomla.
the class StoreGoodsActivity method onGoodBalanceChanged.
/**
* Receives the given <code>goodBalanceChangedEvent</code>. Upon notification, fetches the
* good associated with the given <code>goodBalanceChangedEvent</code> and displays its price
* and the balance.
*
* @param goodBalanceChangedEvent the event received
*/
@Subscribe
public void onGoodBalanceChanged(GoodBalanceChangedEvent goodBalanceChangedEvent) {
VirtualGood good = null;
try {
good = (VirtualGood) StoreInfo.getVirtualItem(goodBalanceChangedEvent.getGoodItemId());
int id = 0;
for (int i = 0; i < StoreInfo.getGoods().size(); i++) {
if (StoreInfo.getGoods().get(i).getItemId().equals(good.getItemId())) {
id = i;
break;
}
}
ListView list = (ListView) findViewById(R.id.list);
TextView info = (TextView) list.getChildAt(id).findViewById(R.id.item_info);
PurchaseType purchaseType = good.getPurchaseType();
if (purchaseType instanceof PurchaseWithVirtualItem) {
info.setText("price: " + ((PurchaseWithVirtualItem) purchaseType).getAmount() + " balance: " + goodBalanceChangedEvent.getBalance());
}
} catch (VirtualItemNotFoundException e) {
SoomlaUtils.LogDebug("StoreGoodsActivity", e.getMessage());
}
}
use of com.squareup.otto.Subscribe in project philm by chrisbanes.
the class MovieController method onMovieWatchingChanged.
@Subscribe
public void onMovieWatchingChanged(MoviesState.WatchingMovieUpdatedEvent event) {
WatchingMovie watching = mMoviesState.getWatchingMovie();
if (watching != null && watching.movie != null) {
fetchDetailMovieIfNeeded(0, watching.movie.getImdbId());
}
populateUiFromQueryType(MovieQueryType.MOVIE_DETAIL);
}
use of com.squareup.otto.Subscribe in project philm by chrisbanes.
the class UserController method onNetworkError.
@Subscribe
public void onNetworkError(BaseState.OnErrorEvent event) {
if (event.error == NetworkError.UNAUTHORIZED_TRAKT && mUserState.getCurrentAccount() != null) {
mPhilmAccountManager.removeAccount(mUserState.getCurrentAccount());
mUserState.setCurrentAccount(null);
Display display = getDisplay();
if (display != null) {
display.showCredentialsChanged();
}
}
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class VideosActivity method handleDownloadVideo.
@Subscribe
public void handleDownloadVideo(DownloadVideoEvent event) {
Logger.d("handleDownloadVideo");
File file = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "mp4");
String url;
if (file != null) {
url = file.getUrl();
String fileId = event.mFileId;
DataRepository.getInstance(getApplication()).updateDownloadUrl(fileId, url);
} else {
// throw new IllegalStateException("url is null");
UiUtils.showErrorSnackbar(mListView, "Server has returned an empty url for video file");
Logger.e("Server response must contains \"mp\" but server has returned:" + Logger.getObjectDump(event.getEventData().getModelData().getResponse().getBody().getFiles()));
}
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class MainActivity method handleDownloadVideo.
@Subscribe
public void handleDownloadVideo(DownloadVideoEvent event) {
Logger.d("handleDownloadVideo");
File file = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "mp4");
String url;
if (file != null) {
url = file.getUrl();
String fileId = event.mFileId;
DownloadHelper.addVideoToDownloadList(getApplicationContext(), url, fileId);
} else {
// throw new IllegalStateException("url is null");
// UiUtils.showErrorSnackbar(getBaseView(), "Server has returned an empty url for video file");
Logger.e("Server response must contains \"mp\" but server has returned:" + Logger.getObjectDump(event.getEventData().getModelData().getResponse().getBody().getFiles()));
}
}
Aggregations