From 3d9dc47775ad35f3139c4f192a2007785c051295 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:00:20 -0400 Subject: Use openMedia in HistoryPostRecyclerViewAdapter. --- .../adapters/HistoryPostRecyclerViewAdapter.java | 121 +++++---------------- 1 file changed, 27 insertions(+), 94 deletions(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index b9e9b117..5cda5a7f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -2457,6 +2457,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter 0) { + intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, videoProgress); + } intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.IMAGE_TYPE) { @@ -3219,44 +3230,16 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter { - if (canStartActivity) { - canStartActivity = false; - int position = getBindingAdapterPosition(); - if (position < 0) { - return; - } - Post post = getItem(position); - if (post != null) { - Intent intent = new Intent(mActivity, ViewVideoActivity.class); - if (post.isImgur()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isRedgifs()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); - if (post.isLoadRedgifsOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } - } else if (post.isStreamable()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE); - intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, post.getStreamableShortCode()); - if (post.isLoadRedgifsOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } - } else { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName()); - intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId()); - } - intent.putExtra(ViewVideoActivity.EXTRA_POST, post); - if (helper != null) { - intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition()); - } - intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); - mActivity.startActivity(intent); + int position = getBindingAdapterPosition(); + if (position < 0) { + return; + } + Post post = getItem(position); + if (post != null) { + if (helper != null) { + openMedia(post, helper.getLatestPlaybackInfo().getResumePosition()); + } else { + openMedia(post, -1); } } }); @@ -4917,36 +4900,11 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter