111
111
import ml .docilealligator .infinityforreddit .post .FetchPost ;
112
112
import ml .docilealligator .infinityforreddit .post .Post ;
113
113
import ml .docilealligator .infinityforreddit .services .DownloadMediaService ;
114
+ import ml .docilealligator .infinityforreddit .services .DownloadRedditVideoService ;
114
115
import ml .docilealligator .infinityforreddit .utils .APIUtils ;
115
116
import ml .docilealligator .infinityforreddit .utils .SharedPreferencesUtils ;
116
117
import ml .docilealligator .infinityforreddit .utils .Utils ;
@@ -981,31 +982,6 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
981
982
private void download () {
982
983
isDownloading = false ;
983
984
984
- /*Intent intent;
985
- if (videoType != VIDEO_TYPE_NORMAL) {
986
- intent = new Intent(this, DownloadMediaService.class);
987
- if (post.getPostType() == Post.GIF_TYPE) {
988
- intent.putExtra(DownloadMediaService.EXTRA_URL, post.getVideoUrl());
989
- intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_GIF);
990
- intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, post.getSubredditName()
991
- + "-" + post.getId() + ".gif");
992
- } else {
993
- intent.putExtra(DownloadMediaService.EXTRA_URL, videoDownloadUrl);
994
- intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO);
995
- intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, videoFileName);
996
- }
997
-
998
- intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
999
- intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNSFW);
1000
- } else {
1001
- intent = new Intent(this, DownloadRedditVideoService.class);
1002
- intent.putExtra(DownloadRedditVideoService.EXTRA_VIDEO_URL, videoDownloadUrl);
1003
- intent.putExtra(DownloadRedditVideoService.EXTRA_POST_ID, id);
1004
- intent.putExtra(DownloadRedditVideoService.EXTRA_SUBREDDIT, subredditName);
1005
- intent.putExtra(DownloadRedditVideoService.EXTRA_IS_NSFW, isNSFW);
1006
- }
1007
- ContextCompat.startForegroundService(this, intent);*/
1008
-
1009
985
if (videoType != VIDEO_TYPE_NORMAL ) {
1010
986
PersistableBundle extras = new PersistableBundle ();
1011
987
if (post .getPostType () == Post .GIF_TYPE ) {
@@ -1026,11 +1002,15 @@ private void download() {
1026
1002
JobInfo jobInfo = DownloadMediaService .constructJobInfo (this , 5000000 , extras );
1027
1003
((JobScheduler ) getSystemService (Context .JOB_SCHEDULER_SERVICE )).schedule (jobInfo );
1028
1004
} else {
1029
- /* intent = new Intent(this, DownloadRedditVideoService.class);
1030
- intent.putExtra(DownloadRedditVideoService.EXTRA_VIDEO_URL, videoDownloadUrl);
1031
- intent.putExtra(DownloadRedditVideoService.EXTRA_POST_ID, id);
1032
- intent.putExtra(DownloadRedditVideoService.EXTRA_SUBREDDIT, subredditName);
1033
- intent.putExtra(DownloadRedditVideoService.EXTRA_IS_NSFW, isNSFW);*/
1005
+ PersistableBundle extras = new PersistableBundle ();
1006
+ extras .putString (DownloadRedditVideoService .EXTRA_VIDEO_URL , videoDownloadUrl );
1007
+ extras .putString (DownloadRedditVideoService .EXTRA_POST_ID , id );
1008
+ extras .putString (DownloadRedditVideoService .EXTRA_SUBREDDIT , subredditName );
1009
+ extras .putInt (DownloadRedditVideoService .EXTRA_IS_NSFW , isNSFW ? 1 : 0 );
1010
+
1011
+ //TODO: contentEstimatedBytes
1012
+ JobInfo jobInfo = DownloadRedditVideoService .constructJobInfo (this , 5000000 , extras );
1013
+ ((JobScheduler ) getSystemService (Context .JOB_SCHEDULER_SERVICE )).schedule (jobInfo );
1034
1014
}
1035
1015
1036
1016
Toast .makeText (this , R .string .download_started , Toast .LENGTH_SHORT ).show ();
0 commit comments