Search in sources :

Example 51 with Subscribe

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

the class FavoritesFragment method handleRetrieveVideo.

@Subscribe
public void handleRetrieveVideo(VideoListEvent event) {
    Logger.d("handleRetrieveVideo(): size=" + event.getEventData().getModelData().getVideoData().size());
    VideoList data = event.getEventData().getModelData();
    if (data.getVideoData().size() > 0) {
        for (VideoData item : data.getVideoData()) {
            if (!TextUtils.isEmpty(DataHelper.getFavoriteId(getActivity().getContentResolver(), item.getId()))) {
                List<VideoData> videos = new ArrayList<>();
                videos.add(item);
                DataHelper.insertVideos(getActivity().getContentResolver(), videos);
                DataHelper.setFavoriteVideo(getActivity().getContentResolver(), item.getId(), true);
            }
        }
    }
}
Also used : VideoList(com.zype.android.webapi.model.video.VideoList) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) ArrayList(java.util.ArrayList) Subscribe(com.squareup.otto.Subscribe)

Example 52 with Subscribe

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

the class MainActivity method handleConsumer.

// @Override
// public void openVideoFragment(String url) {
// Logger.d("openVideoFragment " + url);
// //        LatestFragment f = (LatestFragment) adapterPager.getItem(0);
// //        f.showVideoFragment(url);
// }
// -------------------SUBSCRIBE-------------------
@Subscribe
public void handleConsumer(ConsumerEvent event) {
    Logger.d("handleConsumer");
    Consumer data = event.getEventData().getModelData();
    int subscriptionCount = data.getConsumerData().getSubscriptionCount();
    SettingsProvider.getInstance().saveSubscriptionCount(subscriptionCount);
}
Also used : Consumer(com.zype.android.webapi.model.consumers.Consumer) Subscribe(com.squareup.otto.Subscribe)

Example 53 with Subscribe

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

the class MainActivity method handleDownloadAudio.

@Subscribe
public void handleDownloadAudio(DownloadAudioEvent event) {
    Logger.d("handleDownloadAudio");
    File file = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "m4a");
    String url;
    if (file != null) {
        url = file.getUrl();
        String fileId = event.mFileId;
        DownloadHelper.addAudioToDownloadList(getApplicationContext(), url, fileId);
    } else {
        // throw new IllegalStateException("url is null");
        // UiUtils.showErrorSnackbar(getBaseView(), "Server has returned an empty url for audio file");
        Logger.e("Server response must contains \"m4a\" 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 54 with Subscribe

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

the class VideosActivity method handleRetrieveVideo.

// //////////
// Subscriptions
// 
@Subscribe
public void handleRetrieveVideo(VideoListEvent event) {
    List<VideoData> result = event.getEventData().getModelData().getVideoData();
    Pagination pagination = event.getEventData().getModelData().getPagination();
    if (result != null) {
        Logger.d("handleRetrieveVideo(): size=" + result.size());
        if (result.size() > 0) {
            if (mVideoList == null || pagination.getCurrent() == 1) {
                mVideoList = new ArrayList<>(result);
                SharedPref.save(playlistId, true);
            } else {
                mVideoList.addAll(result);
            }
            if (Pagination.hasNextPage(pagination)) {
                loadVideosFromPlaylist(Pagination.getNextPage(pagination));
            } else {
                int videosAdded = DataHelper.insertVideos(this.getContentResolver(), mVideoList);
                Logger.d("handleRetrieveVideo(): added " + videosAdded + " videos");
                DataHelper.addVideosToPlaylist(this.getContentResolver(), mVideoList, playlistId);
                DataHelper.clearPlaylistVideo(this.getContentResolver(), playlistId);
                int itemsInsertedPlaylistVideo = DataHelper.insertPlaylistVideo(this.getContentResolver(), mVideoList, playlistId, 0);
                Logger.d("handleRetrieveVideo(): PlaylistVideo inserted=" + itemsInsertedPlaylistVideo);
            // if (videosAdded > 0) {
            // startLoadCursors();
            // }
            }
        }
    }
}
Also used : Pagination(com.zype.android.webapi.model.video.Pagination) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) Subscribe(com.squareup.otto.Subscribe)

Example 55 with Subscribe

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

the class VideosActivity method handleVideoEntitlementEvent.

@Subscribe
public void handleVideoEntitlementEvent(VideoEntitlementEvent event) {
    Logger.d("handleVideoEntitlementEvent()");
    Bundle requestOptions = event.getOptions();
    HashMap<String, String> pathParams = (HashMap<String, String>) requestOptions.getSerializable(ParamsBuilder.PATH_PARAMS);
    String videoId = pathParams.get(EntitlementParamsBuilder.VIDEO_ID);
    VideoDetailActivity.startActivity(this, videoId, playlistId);
}
Also used : HashMap(java.util.HashMap) Bundle(android.os.Bundle) Subscribe(com.squareup.otto.Subscribe)

Aggregations

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