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