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