Search in sources :

Example 1 with VideoData

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

the class VideosActivity method handleRetrieveVideo.

// //////////
// Subscriptions
// 
@Subscribe
public void handleRetrieveVideo(RetrieveVideoEvent event) {
    List<VideoData> result = event.getEventData().getModelData().getVideoData();
    Pagination pagination = event.getEventData().getModelData().getPagination();
    if (result != null) {
        Logger.d("handleRetrieveVideo(): size=" + result.size());
        if (result.size() > 0) {
            if (mVideoList == null || pagination.getCurrent() == 1) {
                mVideoList = new ArrayList<>(result);
            } else {
                mVideoList.addAll(result);
            }
            if (Pagination.hasNextPage(pagination)) {
                loadVideosFromPlaylist(Pagination.getNextPage(pagination));
            } else {
                int videosAdded = DataHelper.insertVideos(this.getContentResolver(), mVideoList);
                Logger.d("handleRetrieveVideo(): added " + videosAdded + " videos");
                DataHelper.addVideosToPlaylist(this.getContentResolver(), mVideoList, playlistId);
                DataHelper.clearPlaylistVideo(this.getContentResolver(), playlistId);
                int itemsInsertedPlaylistVideo = DataHelper.insertPlaylistVideo(this.getContentResolver(), mVideoList, playlistId, 0);
                Logger.d("handleRetrieveVideo(): PlaylistVideo inserted=" + itemsInsertedPlaylistVideo);
            // if (videosAdded > 0) {
            // startLoadCursors();
            // }
            }
        }
    }
}
Also used : Pagination(com.zype.android.webapi.model.video.Pagination) VideoData(com.zype.android.webapi.model.video.VideoData) ConsumerFavoriteVideoData(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData) Subscribe(com.squareup.otto.Subscribe)

Example 2 with VideoData

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

the class PlayerFragment method showNotification.

public void showNotification(boolean isLive, int type) {
    VideoData video = VideoHelper.getVideo(getActivity().getContentResolver(), fileId);
    String title = "";
    if (video != null) {
        title = video.getTitle();
    } else {
        title = "Live";
    }
    Intent notificationIntent;
    Bundle bundle = new Bundle();
    if (isLive) {
        notificationIntent = new Intent(getActivity(), LivePlayerActivity.class);
        bundle.putInt(BundleConstants.VIDEO_TYPE, type);
        title = "Live";
    } else {
        notificationIntent = new Intent(getActivity(), VideoDetailActivity.class);
    }
    notificationIntent.putExtras(bundle);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    PendingIntent intent = PendingIntent.getActivity(getActivity(), 0, notificationIntent, 0);
    Notification.Builder builder = new Notification.Builder(getActivity());
    builder.setContentIntent(intent).setSmallIcon(R.drawable.ic_notif).setContentTitle(getActivity().getString(R.string.app_name)).setContentIntent(intent).setPriority(Notification.PRIORITY_HIGH).setContentText(title).setAutoCancel(true).setOngoing(true).setWhen(0).setOngoing(true).setContentTitle(title);
    Intent stopIntent = new Intent();
    stopIntent.setAction(MEDIA_STOP);
    PendingIntent pendingIntentStop = PendingIntent.getBroadcast(getActivity(), 12345, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    Notification not = builder.setPriority(Notification.PRIORITY_MAX).addAction(R.drawable.ic_stop_black_24px, "Stop", pendingIntentStop).setWhen(0).build();
    NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(ZypeApp.NOTIFICATION_ID, not);
}
Also used : LivePlayerActivity(com.zype.android.ui.chromecast.LivePlayerActivity) NotificationManager(android.app.NotificationManager) Bundle(android.os.Bundle) VideoData(com.zype.android.webapi.model.video.VideoData) VideoDetailActivity(com.zype.android.ui.video_details.VideoDetailActivity) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 3 with VideoData

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

the class SummaryFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final View view = inflater.inflate(R.layout.fragment_summary, container, false);
    Cursor cursor = CursorHelper.getVideoCursor(getActivity().getContentResolver(), videoId);
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            VideoData video = VideoHelper.objectFromCursor(cursor);
            ((TextView) view.findViewById(R.id.textVideoTitle)).setText(video.getTitle());
            ((TextView) view.findViewById(R.id.textVideoDescription)).setText(video.getDescription());
        // TagCloudLinkView tagCloudView = (TagCloudLinkView) view.findViewById(R.id.tag_cloud);
        // hide keywords
        /* if (video.getKeywords() != null) {
                    for (int i = 0; i < video.getKeywords().size(); i++) {
                        tagCloudView.add(new Tag(i, video.getKeywords().get(i)));
                    }
                    tagCloudView.drawTags();
                    tagCloudView.setOnTagSelectListener(new TagCloudLinkView.OnTagSelectListener() {
                        @Override
                        public void onTagSelected(Tag tag, int i) {
//                            UiUtils.showWarningSnackbar(view, tag.getText());
                        }
                    });
                }*/
        } else {
            throw new IllegalStateException("DB not contains video with ID=" + videoId);
        }
        cursor.close();
    }
    return view;
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) TextView(android.widget.TextView) Cursor(android.database.Cursor) TextView(android.widget.TextView) TagCloudLinkView(com.ns.developer.tagview.widget.TagCloudLinkView) View(android.view.View)

Example 4 with VideoData

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

the class StorageUtils method checkSizeOfDownloads.

public static void checkSizeOfDownloads(MainActivity context) {
    List<VideoData> videos = VideoHelper.getAllDownloads(context.getContentResolver());
    if (videos != null) {
        for (int i = 0; i < videos.size(); i++) {
            if (videos.get(i).getDownloadAudioPath() != null && !TextUtils.isEmpty(videos.get(i).getDownloadAudioPath())) {
                File file = new File(videos.get(i).getDownloadAudioPath());
                SettingsProvider.getInstance().addToReserved(file.length());
            }
            if (videos.get(i).getDownloadVideoPath() != null && !TextUtils.isEmpty(videos.get(i).getDownloadVideoPath())) {
                File file = new File(videos.get(i).getDownloadVideoPath());
                SettingsProvider.getInstance().addToReserved(file.length());
            }
        }
    }
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) File(java.io.File)

Example 5 with VideoData

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

the class UiUtils method shareVideo.

public static void shareVideo(Activity activity, String videoId) {
    Intent sendIntent = new Intent();
    VideoData video = VideoHelper.getVideo(activity.getContentResolver(), videoId);
    String title = video.getTitle();
    String imageUrl = "";
    if (video.getThumbnails() != null && video.getThumbnails().size() > 0) {
        imageUrl = video.getThumbnails().get(video.getThumbnails().size() - 1).getUrl();
    }
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, SettingsProvider.getInstance().getShareSubject());
    String message = String.format(activity.getString(R.string.share_message), title, activity.getString(R.string.app_name));
    sendIntent.putExtra(Intent.EXTRA_TEXT, message);
    sendIntent.setType("text/html");
    activity.startActivity(Intent.createChooser(sendIntent, activity.getResources().getText(R.string.menu_share)));
}
Also used : VideoData(com.zype.android.webapi.model.video.VideoData) Intent(android.content.Intent)

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