use of com.squareup.otto.Subscribe in project zype-android by zype.
the class VideoDetailActivity 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;
DataHelper.saveVideoUrl(getContentResolver(), fileId, url);
initUI();
} else {
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 VideoDetailActivity method handleVideoPlayer.
@Subscribe
public void handleVideoPlayer(PlayerVideoEvent event) {
Logger.d("handlePlayer");
String url = event.getEventData().getModelData().getResponse().getBody().getFiles().get(0).getUrl();
DataHelper.saveVideoPlayerLink(getContentResolver(), mVideoId, url);
Advertising advertising = event.getEventData().getModelData().getResponse().getBody().getAdvertising();
Analytics analytics = event.getEventData().getModelData().getResponse().getBody().getAnalytics();
if (advertising != null) {
List<AdvertisingSchedule> schedule = advertising.getSchedule();
DataHelper.updateAdSchedule(getContentResolver(), mVideoId, schedule);
// in the 'VideoList' table. But we do this now because the tags are the same for all ad cue points
if (schedule != null && !schedule.isEmpty()) {
String adTag = advertising.getSchedule().get(0).getTag();
DataHelper.saveAdVideoTag(getContentResolver(), mVideoId, adTag);
}
}
if (analytics != null) {
String beacon = analytics.getBeacon();
AnalyticsDimensions dimensions = analytics.getDimensions();
if (beacon != null && dimensions != null) {
DataHelper.updateAnalytics(getContentResolver(), beacon, dimensions);
}
}
mType = PlayerFragment.TYPE_VIDEO_WEB;
changeFragment(isChromecastConntected());
hideProgress();
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class VideoDetailViewModel method handleDownloadAudio.
/**
* Handles API request for player audio download url
*
* @param event Response event
*/
@Subscribe
public void handleDownloadAudio(DownloadAudioEvent event) {
File fileM4A = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "m4a");
File fileMP3 = ListUtils.getFileByType(event.getEventData().getModelData().getResponse().getBody().getFiles(), "mp3");
File file = null;
if (fileM4A != null)
file = fileM4A;
else if (fileMP3 != null)
file = fileMP3;
String url;
if (file != null) {
url = file.getUrl();
String videoId = event.mFileId;
// Save download url in the local database if it was changed
Video video = repo.getVideoSync(videoId);
video.downloadAudioUrl = url;
repo.updateVideo(video);
if (!TextUtils.isEmpty(url)) {
downloadsAvailableLiveData.setValue(true);
}
} else {
Logger.e("handleDownloadVideo(): m4a or mp3 source not found");
}
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class HeroImagesViewModel method handleVideo.
/**
* Handles API request for playlist
*
* @param event Response event
*/
@Subscribe
public void handleVideo(VideoEvent event) {
Logger.d("handleVideo()");
VideoData data = event.getEventData().getModelData().getVideoData();
Video video = DbHelper.videoDataToVideoEntity(data);
if (video != null) {
List<Video> videosList = Arrays.asList(video);
repo.insertVideos(videosList);
}
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class MarketplaceGateway method handlePlan.
//
// Zype API
//
@Subscribe
public void handlePlan(PlanEvent event) {
Logger.d("handlePlan()");
PlanData data = event.getEventData().getModelData().data;
Subscription subscription = new Subscription();
subscription.setZypePlan(data);
subscriptionsLiveData.getValue().put(data.id, subscription);
queryGooglePlayProduct(subscription);
}
Aggregations