Search in sources :

Example 1 with Category

use of com.zype.android.webapi.model.video.Category in project zype-android by zype.

the class VideoHelper method objectFromCursor.

@NonNull
public static VideoData objectFromCursor(@NonNull Cursor cursor) {
    Gson gson = new Gson();
    VideoData video = VideoData.newVideo(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_ID)), cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_ACTIVE)) == 1, cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_COUNTRY)));
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_CATEGORY)) != null) {
        Type categoryType = new TypeToken<List<Category>>() {
        }.getType();
        video.setCategories(gson.<List<Category>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_CATEGORY)), categoryType));
    }
    video.setCreatedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_CREATED_AT)));
    video.setDescription(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_DESCRIPTION)));
    video.setDiscoveryUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_DISCOVERY_URL)));
    video.setDuration(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_DURATION)));
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_GUESTS)) != null) {
        Type guestsType = new TypeToken<List<ZObject>>() {
        }.getType();
        video.setGuests(gson.<List<ZObject>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_GUESTS)), guestsType));
    }
    video.setEpisode(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_EPISODE)));
    video.setExpireAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_EXPIRE_AT)));
    video.setFeatured(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_FEATURED)) == 1);
    video.setForeignId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_FOREIGN_ID)));
    video.setMatureContent(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_MATURE_CONTENT)) == 1);
    video.setOnAir(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_ON_AIR)) == 1);
    video.setPlayingPosition(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_PLAY_TIME)));
    video.setPlayerAudioUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PLAYER_AUDIO_URL)));
    video.setPlayerVideoUrl(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PLAYER_VIDEO_URL)));
    video.setPublishedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_PUBLISHED_AT)));
    video.setRating(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_RATING)));
    video.setRequestCount(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_REQUEST_COUNT)));
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_RELATED_PLAYLIST_IDS)) != null) {
        Type relatedPlaylistIdsType = new TypeToken<List<String>>() {
        }.getType();
        video.setRelatedPlaylistIds(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_RELATED_PLAYLIST_IDS)), relatedPlaylistIdsType));
    }
    video.setSeason(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SEASON)));
    video.setShortDescription(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SHORT_DESCRIPTION)));
    video.setSiteId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_SITE_ID)));
    video.setStartAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_START_AT)));
    video.setStatus(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_STATUS)));
    video.setSubscriptionRequired(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_SUBSCRIPTION_REQUIRED)) == 1);
    video.setTitle(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_TITLE)));
    try {
        if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_THUMBNAILS)) != null) {
            Type thumbnailType = new TypeToken<List<Thumbnail>>() {
            }.getType();
            video.setThumbnails(gson.<List<Thumbnail>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_THUMBNAILS)), thumbnailType));
        }
    } catch (IllegalStateException e) {
        Logger.e("objectFromCursor", e);
    }
    video.setUpdatedAt(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_UPDATED_AT)));
    video.setHuluId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_HULU_ID)));
    video.setYoutubeId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_YOUTUBE_ID)));
    video.setTranscoded(cursor.getInt(cursor.getColumnIndex(Contract.Video.COLUMN_TRANSCODED)) == 1);
    video.setCrunchyrollId(cursor.getString(cursor.getColumnIndex(Contract.Video.COLUMN_CRUNCHYROLL_ID)));
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_KEYWORDS)) != null) {
        Type keywordsType = new TypeToken<List<String>>() {
        }.getType();
        video.setKeywords(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_KEYWORDS)), keywordsType));
    }
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_VIDEO_ZOBJECTS)) != null) {
        Type videoZObjectsType = new TypeToken<List<VideoZobject>>() {
        }.getType();
        video.setVideoZobjects(gson.<List<VideoZobject>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_VIDEO_ZOBJECTS)), videoZObjectsType));
    }
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_ZOBJECT_IDS)) != null) {
        Type zObjectIdsType = new TypeToken<List<String>>() {
        }.getType();
        video.setZobjectIds(gson.<List<String>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_ZOBJECT_IDS)), zObjectIdsType));
    }
    if (cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_SEGMENTS)) != null) {
        Type segmentType = new TypeToken<List<Segment>>() {
        }.getType();
        video.setSegments(gson.<List<Segment>>fromJson(cursor.getString(cursor.getColumnIndexOrThrow(Contract.Video.COLUMN_SEGMENTS)), segmentType));
    }
    video.setPurchaseRequired(cursor.getInt(cursor.getColumnIndex(Contract.Video.PURCHASE_REQUIRED)) == 1);
    return video;
}
Also used : VideoZobject(com.zype.android.webapi.model.video.VideoZobject) Category(com.zype.android.webapi.model.video.Category) Gson(com.google.gson.Gson) Thumbnail(com.zype.android.webapi.model.video.Thumbnail) Segment(com.zype.android.webapi.model.search.Segment) ZObject(com.zype.android.webapi.model.zobjects.ZObject) Type(java.lang.reflect.Type) VideoData(com.zype.android.webapi.model.video.VideoData) ArrayList(java.util.ArrayList) List(java.util.List) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)1 Gson (com.google.gson.Gson)1 Segment (com.zype.android.webapi.model.search.Segment)1 Category (com.zype.android.webapi.model.video.Category)1 Thumbnail (com.zype.android.webapi.model.video.Thumbnail)1 VideoData (com.zype.android.webapi.model.video.VideoData)1 VideoZobject (com.zype.android.webapi.model.video.VideoZobject)1 ZObject (com.zype.android.webapi.model.zobjects.ZObject)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1