aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-06-21 23:00:20 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-06-21 23:00:20 +0000
commit3d9dc47775ad35f3139c4f192a2007785c051295 (patch)
tree79dc7c08ccd3f36f9a24f6ae9400cf62e09e8409 /app/src
parent31b2c123dce4e7441563d94302480fa1f81ae93f (diff)
downloadinfinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar.gz
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar.bz2
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar.lz
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar.xz
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.tar.zst
infinity-for-reddit-3d9dc47775ad35f3139c4f192a2007785c051295.zip
Use openMedia in HistoryPostRecyclerViewAdapter.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java121
1 files changed, 27 insertions, 94 deletions
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<Post, Recy
}
private void openMedia(Post post, int galleryItemIndex) {
+ openMedia(post, galleryItemIndex, -1);
+ }
+
+ private void openMedia(Post post, long videoProgress) {
+ openMedia(post, 0, videoProgress);
+ }
+
+ private void openMedia(Post post, int galleryItemIndex, long videoProgress) {
if (canStartActivity) {
canStartActivity = false;
if (post.getPostType() == Post.VIDEO_TYPE) {
@@ -2485,6 +2493,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
intent.putExtra(ViewVideoActivity.EXTRA_POST, post);
+ if (videoProgress > 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<Post, Recy
});
fullscreenButton.setOnClickListener(view -> {
- 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<Post, Recy
}
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());
+ openMedia(post, helper.getLatestPlaybackInfo().getResumePosition());
+ } else {
+ openMedia(post, -1);
}
- intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
- mActivity.startActivity(intent);
}
});
@@ -5925,36 +5883,11 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
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());
+ openMedia(post, helper.getLatestPlaybackInfo().getResumePosition());
+ } else {
+ openMedia(post, -1);
}
- intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW());
- mActivity.startActivity(intent);
}
});