mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-27 01:54:45 +01:00
Parse video posts
Parse post with direct links to videos as Video type posts. Autoplay also works with these.
This commit is contained in:
parent
84d90adc54
commit
888e741aa9
@ -438,7 +438,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
return new PostDetailVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_detail_video_autoplay_legacy_controller : R.layout.item_post_detail_video_autoplay, parent, false));
|
||||
case VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW:
|
||||
if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
|
||||
if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts) || mPost.getPreviews().isEmpty()) {
|
||||
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
|
||||
}
|
||||
return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false));
|
||||
@ -1765,8 +1765,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
} else {
|
||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||
|
||||
}
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||
if (helper != null) {
|
||||
@ -2038,8 +2038,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
||||
} else {
|
||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||
}
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||
@ -2377,7 +2376,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
||||
} else {
|
||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||
}
|
||||
|
@ -2249,8 +2249,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, post.getStreamableShortCode());
|
||||
} else {
|
||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||
}
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||
|
@ -211,10 +211,11 @@ public class ParsePost {
|
||||
String distinguished, String suggestedSort) throws JSONException {
|
||||
Post post;
|
||||
|
||||
boolean isVideo = false;
|
||||
|
||||
String url = (!data.getJSONObject("post").isNull("url")) ? data.getJSONObject("post").getString("url") : "";
|
||||
Uri uri = Uri.parse(url);
|
||||
String path = uri.getPath();
|
||||
boolean isVideo = path.endsWith(".mp4") || path.endsWith(".webm") || path.endsWith(".gifv");
|
||||
|
||||
if (!data.getJSONObject("post").has("thumbnail_url") && previews.isEmpty()) {
|
||||
if (!data.getJSONObject("post").isNull("body") && url.equals("")) {
|
||||
@ -244,16 +245,13 @@ public class ParsePost {
|
||||
} else {
|
||||
if (isVideo) {
|
||||
//No preview video post
|
||||
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
|
||||
int postType = Post.VIDEO_TYPE;
|
||||
String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
|
||||
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
||||
|
||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFull, postTimeMillis, title, permalink, score, postType, voteType,
|
||||
nComments, upvoteRatio, nsfw, locked, saved, distinguished, suggestedSort);
|
||||
|
||||
post.setVideoUrl(videoUrl);
|
||||
post.setVideoDownloadUrl(videoDownloadUrl);
|
||||
post.setVideoUrl(url);
|
||||
post.setVideoDownloadUrl(url);
|
||||
} else if (!url.equals("")) {
|
||||
//No preview link post
|
||||
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user