From c1591dffa764eb16e1f825fceab0c04ac4456af4 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 1 Mar 2020 01:25:06 -0800 Subject: Rearrange image activity to use download manager --- app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt index 3c713ec9..60c642f4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt @@ -40,7 +40,7 @@ import com.pitchedapps.frost.facebook.USER_AGENT * With reference to Stack Overflow */ fun Context.frostDownload( - cookie: CookieEntity, + cookie: String?, url: String?, userAgent: String = USER_AGENT, contentDisposition: String? = null, @@ -52,7 +52,7 @@ fun Context.frostDownload( } fun Context.frostDownload( - cookie: CookieEntity, + cookie: String?, uri: Uri?, userAgent: String = USER_AGENT, contentDisposition: String? = null, @@ -82,7 +82,9 @@ fun Context.frostDownload( val request = DownloadManager.Request(uri) request.setMimeType(mimeType) val title = URLUtil.guessFileName(uri.toString(), contentDisposition, mimeType) - request.addRequestHeader("Cookie", cookie.cookie) + if (cookie != null) { + request.addRequestHeader("Cookie", cookie) + } request.addRequestHeader("User-Agent", userAgent) request.setDescription(string(R.string.downloading)) request.setTitle(title) -- cgit v1.2.3