Search in sources :

Example 26 with Subscribe

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());
    }
}
Also used : VirtualGood(com.soomla.store.domain.virtualGoods.VirtualGood) PurchaseWithVirtualItem(com.soomla.store.purchaseTypes.PurchaseWithVirtualItem) VirtualItemNotFoundException(com.soomla.store.exceptions.VirtualItemNotFoundException) ListView(android.widget.ListView) PurchaseType(com.soomla.store.purchaseTypes.PurchaseType) TextView(android.widget.TextView) Subscribe(com.squareup.otto.Subscribe)

Example 27 with Subscribe

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);
}
Also used : WatchingMovie(app.philm.in.model.WatchingMovie) Subscribe(com.squareup.otto.Subscribe)

Example 28 with Subscribe

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();
        }
    }
}
Also used : Display(app.philm.in.Display) Subscribe(com.squareup.otto.Subscribe)

Example 29 with Subscribe

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()));
    }
}
Also used : File(com.zype.android.webapi.model.player.File) Subscribe(com.squareup.otto.Subscribe)

Example 30 with Subscribe

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()));
    }
}
Also used : File(com.zype.android.webapi.model.player.File) 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