aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-18 17:13:24 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-18 17:13:24 +0000
commit4799a09b42bb6762d2d14363a3c4a68dd7b041b6 (patch)
treeb112e0cf60a22ad6f025323bcc503c72c08e9156 /app/src/main/java/ml
parent3552a9a490c64eec8e56f55fef2b359bcdabe5d1 (diff)
downloadinfinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar.gz
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar.bz2
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar.lz
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar.xz
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.tar.zst
infinity-for-reddit-4799a09b42bb6762d2d14363a3c4a68dd7b041b6.zip
Use the better constructJobInfo() in DownloadMediaService when downloading media in an imgur album.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java10
2 files changed, 4 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java
index a201210e..4ce6827b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java
@@ -12,7 +12,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
-import android.os.PersistableBundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -43,7 +42,6 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.BuildConfig;
-import ml.docilealligator.infinityforreddit.post.ImgurMedia;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback;
@@ -51,6 +49,7 @@ import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.asynctasks.SaveBitmapImageToFile;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SetAsWallpaperBottomSheetFragment;
import ml.docilealligator.infinityforreddit.databinding.FragmentViewImgurImageBinding;
+import ml.docilealligator.infinityforreddit.post.ImgurMedia;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -224,13 +223,8 @@ public class ViewImgurImageFragment extends Fragment {
private void download() {
isDownloading = false;
- PersistableBundle extras = new PersistableBundle();
- extras.putString(DownloadMediaService.EXTRA_URL, imgurMedia.getLink());
- extras.putInt(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE);
- extras.putString(DownloadMediaService.EXTRA_FILE_NAME, imgurMedia.getFileName());
-
//TODO: contentEstimatedBytes
- JobInfo jobInfo = DownloadMediaService.constructJobInfo(activity, 5000000, extras);
+ JobInfo jobInfo = DownloadMediaService.constructJobInfo(activity, 5000000, imgurMedia);
((JobScheduler) activity.getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java
index e3b5b8ac..0d0c7212 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java
@@ -11,7 +11,6 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
-import android.os.PersistableBundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -49,12 +48,12 @@ import com.google.common.collect.ImmutableList;
import javax.inject.Inject;
import javax.inject.Named;
-import ml.docilealligator.infinityforreddit.post.ImgurMedia;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PlaybackSpeedBottomSheetFragment;
import ml.docilealligator.infinityforreddit.databinding.FragmentViewImgurVideoBinding;
+import ml.docilealligator.infinityforreddit.post.ImgurMedia;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -260,13 +259,8 @@ public class ViewImgurVideoFragment extends Fragment {
private void download() {
isDownloading = false;
- PersistableBundle extras = new PersistableBundle();
- extras.putString(DownloadMediaService.EXTRA_URL, imgurMedia.getLink());
- extras.putInt(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO);
- extras.putString(DownloadMediaService.EXTRA_FILE_NAME, imgurMedia.getFileName());
-
//TODO: contentEstimatedBytes
- JobInfo jobInfo = DownloadMediaService.constructJobInfo(activity, 5000000, extras);
+ JobInfo jobInfo = DownloadMediaService.constructJobInfo(activity, 5000000, imgurMedia);
((JobScheduler) activity.getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show();