Search in sources :

Example 6 with VideoData

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

the class VideoHelper method getAllDownloads.

@Nullable
public static List<VideoData> getAllDownloads(ContentResolver contentResolver) {
    List<VideoData> downloads = new ArrayList<>();
    Cursor cursor = CursorHelper.getAllDownloadsCursor(contentResolver);
    VideoData videoData;
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                videoData = VideoHelper.objectFromCursor(cursor);
                videoData = VideoHelper.getDownloadedData(cursor, videoData);
                downloads.add(videoData);
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    return downloads;
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Nullable(android.support.annotation.Nullable)

Example 7 with VideoData

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

the class VideoHelper method removeFavoritesInLocalVideoDb.

@Nullable
public static void removeFavoritesInLocalVideoDb(ContentResolver contentResolver) {
    List<VideoData> favoritesList = new ArrayList<>();
    Cursor cursor = CursorHelper.getAllFavoritesVideoCursor(contentResolver);
    VideoData videoData;
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                videoData = VideoHelper.objectFromCursor(cursor);
                videoData = VideoHelper.getDownloadedData(cursor, videoData);
                favoritesList.add(videoData);
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    for (int i = 0; i < favoritesList.size(); i++) {
        Uri uri = Contract.Video.CONTENT_URI;
        ContentValues value = new ContentValues();
        value.put(Contract.Video.COLUMN_IS_FAVORITE, 0);
        contentResolver.update(uri, value, Contract.Video.COLUMN_ID + " =?", new String[] { favoritesList.get(i).getId() });
    }
}
Also used : ContentValues(android.content.ContentValues) VideoData(com.zype.android.webapi.model.video.VideoData) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri) Nullable(android.support.annotation.Nullable)

Example 8 with VideoData

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

the class MyLibraryFragment method handleRetrieveVideo.

@Subscribe
public void handleRetrieveVideo(RetrieveVideoEvent event) {
    Logger.d("handleRetrieveVideo(): size=" + event.getEventData().getModelData().getVideoData().size());
    Video data = event.getEventData().getModelData();
    if (data.getVideoData().size() > 0) {
        for (VideoData item : data.getVideoData()) {
            if (videoEntitlements.containsKey(item.getId())) {
                List<VideoData> videos = new ArrayList<>();
                videos.add(item);
                DataHelper.insertVideos(getActivity().getContentResolver(), videos);
                VideoEntitlementData entitlementData = videoEntitlements.get(item.getId());
                if (entitlementData != null) {
                    VideoHelper.setEntitlement(getActivity().getContentResolver(), item.getId(), true, entitlementData.updatedAt);
                }
            }
        }
    }
}
Also used : Video(com.zype.android.webapi.model.video.Video) ConsumerFavoriteVideo(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) ArrayList(java.util.ArrayList) VideoEntitlementData(com.zype.android.webapi.model.entitlements.VideoEntitlementData) Subscribe(com.squareup.otto.Subscribe)

Example 9 with VideoData

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

the class BaseVideoActivity method onShowAudio.

@Override
public void onShowAudio() {
    if (mInterface != null) {
        mInterface.stop();
    }
    VideoData videoData = VideoHelper.getFullData(getContentResolver(), mVideoId);
    if (!TextUtils.isEmpty(videoData.getDownloadAudioPath())) {
        mType = PlayerFragment.TYPE_AUDIO_LOCAL;
    } else if (!TextUtils.isEmpty(videoData.getPlayerAudioUrl())) {
        mType = PlayerFragment.TYPE_AUDIO_WEB;
    } else {
        requestAudioUrl(mVideoId);
    }
    changeFragment(false);
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData)

Example 10 with VideoData

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

the class FavoritesFragment method handleRetrieveVideo.

@Subscribe
public void handleRetrieveVideo(RetrieveVideoEvent event) {
    Logger.d("handleRetrieveVideo(): size=" + event.getEventData().getModelData().getVideoData().size());
    Video data = event.getEventData().getModelData();
    if (data.getVideoData().size() > 0) {
        for (VideoData item : data.getVideoData()) {
            if (!TextUtils.isEmpty(DataHelper.getFavoriteId(getActivity().getContentResolver(), item.getId()))) {
                List<VideoData> videos = new ArrayList<>();
                videos.add(item);
                DataHelper.insertVideos(getActivity().getContentResolver(), videos);
                DataHelper.setFavoriteVideo(getActivity().getContentResolver(), item.getId(), true);
            }
        }
    }
}
Also used : Video(com.zype.android.webapi.model.video.Video) ConsumerFavoriteVideo(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) ArrayList(java.util.ArrayList) Subscribe(com.squareup.otto.Subscribe)

Aggregations

VideoData (com.zype.android.webapi.model.video.VideoData)16 Cursor (android.database.Cursor)5 Nullable (android.support.annotation.Nullable)5 ArrayList (java.util.ArrayList)5 Subscribe (com.squareup.otto.Subscribe)3 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)3 Intent (android.content.Intent)2 ConsumerFavoriteVideo (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo)2 Video (com.zype.android.webapi.model.video.Video)2 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 TextView (android.widget.TextView)1