Search in sources :

Example 31 with Subscribe

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

Example 32 with Subscribe

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

Example 33 with Subscribe

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

Example 34 with Subscribe

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);
    }
}
Also used : Video(com.zype.android.Db.Entity.Video) VideoData(com.zype.android.webapi.model.video.VideoData) Subscribe(com.squareup.otto.Subscribe)

Example 35 with Subscribe

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