From 20620a67f740709608d128f5a811481290d7d017 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:22:02 -0400 Subject: Download gif in ViewVideoActivity when it's a gif post. --- .../activities/ViewVideoActivity.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 6be51742..49927c8f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -210,6 +210,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe @Inject SimpleCache mSimpleCache; + private Post post; + @OptIn(markerClass = UnstableApi.class) @Override protected void onCreate(Bundle savedInstanceState) { @@ -390,7 +392,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } } - Post post = intent.getParcelableExtra(EXTRA_POST); + post = intent.getParcelableExtra(EXTRA_POST); if (post != null) { binding.getTitleTextView().setText(post.getTitle()); videoFallbackDirectUrl = post.getVideoFallBackDirectUrl(); @@ -975,9 +977,17 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe Intent intent; if (videoType != VIDEO_TYPE_NORMAL) { intent = new Intent(this, DownloadMediaService.class); - intent.putExtra(DownloadMediaService.EXTRA_URL, videoDownloadUrl); - intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO); - intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, videoFileName); + if (post.getPostType() == Post.GIF_TYPE) { + intent.putExtra(DownloadMediaService.EXTRA_URL, post.getVideoUrl()); + intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_GIF); + intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, post.getSubredditName() + + "-" + post.getId() + ".gif"); + } else { + intent.putExtra(DownloadMediaService.EXTRA_URL, videoDownloadUrl); + intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO); + intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, videoFileName); + } + intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName); intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNSFW); } else { -- cgit v1.2.3