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