Story downloader test

video download dead xd
This commit is contained in:
gdlbo
2022-07-09 15:13:13 +03:00
parent 0fefcafba8
commit c65f20f8bb
3 changed files with 51 additions and 0 deletions
@@ -0,0 +1,39 @@
package ru.vtosters.lite.downloaders;
import static com.vtosters.lite.R.*;
import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo;
import static ru.vtosters.lite.utils.Globals.getIdentifier;
import static ru.vtosters.lite.utils.Globals.getString;
import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import com.vk.core.util.AlertDialogs;
import com.vk.dto.common.ImageSize;
import com.vk.dto.stories.model.StoryEntry;
import java.util.List;
public class StoryDownloader{
public static void injectAction(AlertDialogs.b dialogBuilder, StoryEntry story) {
Context ctx = dialogBuilder.a().show().getContext();
dialogBuilder.a(string.download, () -> {
// if story is a pic
if (story.T1()) {
List<ImageSize> imageSizes = story.E.Q.t1();
String url = imageSizes.get(imageSizes.size() - 1).url;
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle("photo" + story.E.a);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DCIM, "/Stories/photo" + story.E.a + ".jpg");
((DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
return;
}
// if story is a video
if (story.M1() && story.F != null) {
downloadVideo(story.F, ctx); // dead
}
});
}
}