aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-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);
}
});