Search in sources :

Example 1 with AdvertisingSchedule

use of com.zype.android.webapi.model.player.AdvertisingSchedule 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 2 with AdvertisingSchedule

use of com.zype.android.webapi.model.player.AdvertisingSchedule in project zype-android by zype.

the class VideoHelper method getAdSchedule.

public static List<AdvertisingSchedule> getAdSchedule(ContentResolver contentResolver, String videoId) {
    List<AdvertisingSchedule> result = new ArrayList<>();
    Cursor cursor = CursorHelper.getAdScheduleCursorByVideoId(contentResolver, videoId);
    if (cursor != null) {
        while (cursor.moveToNext()) {
            AdvertisingSchedule item = new AdvertisingSchedule();
            item.setOffset(cursor.getInt(cursor.getColumnIndexOrThrow(Contract.AdSchedule.OFFSET)));
            item.setTag(cursor.getString(cursor.getColumnIndexOrThrow(Contract.AdSchedule.TAG)));
            result.add(item);
        }
    }
    return result;
}
Also used : AdvertisingSchedule(com.zype.android.webapi.model.player.AdvertisingSchedule) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 3 with AdvertisingSchedule

use of com.zype.android.webapi.model.player.AdvertisingSchedule in project zype-android by zype.

the class DataHelper method updateAdSchedule.

public static int updateAdSchedule(ContentResolver contentResolver, String videoId, List<AdvertisingSchedule> adSchedule) {
    Uri uri = Contract.AdSchedule.CONTENT_URI;
    // Delete current schedule
    int resultDelete = contentResolver.delete(uri, Contract.AdSchedule.VIDEO_ID + "=?", new String[] { videoId });
    if (resultDelete == -1) {
        return resultDelete;
    }
    // Insert new records if schedule is not empty
    if (adSchedule != null && adSchedule.size() > 0) {
        ContentValues[] values = new ContentValues[adSchedule.size()];
        for (int i = 0; i < adSchedule.size(); i++) {
            ContentValues value = new ContentValues();
            AdvertisingSchedule item = adSchedule.get(i);
            value.put(Contract.AdSchedule.OFFSET, item.getOffset());
            value.put(Contract.AdSchedule.TAG, item.getTag());
            value.put(Contract.PlaylistVideo.VIDEO_ID, videoId);
            values[i] = value;
        }
        return contentResolver.bulkInsert(uri, values);
    } else {
        return 0;
    }
}
Also used : ContentValues(android.content.ContentValues) AdvertisingSchedule(com.zype.android.webapi.model.player.AdvertisingSchedule) Uri(android.net.Uri)

Aggregations

AdvertisingSchedule (com.zype.android.webapi.model.player.AdvertisingSchedule)3 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Subscribe (com.squareup.otto.Subscribe)1 Advertising (com.zype.android.webapi.model.player.Advertising)1 Analytics (com.zype.android.webapi.model.player.Analytics)1 AnalyticsDimensions (com.zype.android.webapi.model.player.AnalyticsDimensions)1 ArrayList (java.util.ArrayList)1