aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-03-01 01:25:06 -0800
committerAllan Wang <me@allanwang.ca>2020-03-01 01:25:06 -0800
commitc1591dffa764eb16e1f825fceab0c04ac4456af4 (patch)
treefdc55a1ef36347a62138d2952d435a38affc8435 /app/src/main/kotlin/com/pitchedapps/frost/utils
parent118635f6630487e93a519e9a63151d95b31ee8b1 (diff)
downloadfrost-c1591dffa764eb16e1f825fceab0c04ac4456af4.tar.gz
frost-c1591dffa764eb16e1f825fceab0c04ac4456af4.tar.bz2
frost-c1591dffa764eb16e1f825fceab0c04ac4456af4.zip
Rearrange image activity to use download manager
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt8
1 files changed, 5 insertions, 3 deletions
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 <a href="https://stackoverflow.com/questions/33434532/android-webview-download-files-like-browsers-do">Stack Overflow</a>
*/
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)