diff options
author | Allan Wang <me@allanwang.ca> | 2018-04-13 00:13:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 00:13:28 -0400 |
commit | c5e769deabeb80d7257b85c5c3d802cf46e6b191 (patch) | |
tree | b3ac48678e893495b932c6500025db73a83e3d2b /app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt | |
parent | d9e2562267e549ee407e683262406581f2c4888e (diff) | |
download | frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.tar.gz frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.tar.bz2 frost-c5e769deabeb80d7257b85c5c3d802cf46e6b191.zip |
Fix view full image (#882)v2.0.1
* Test including full photo viewer
* Test cookie in glide
* Fix parser and add redirects to view full image
* Update changelog
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt index 453400d3..8eeef08d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt @@ -11,9 +11,8 @@ import com.bumptech.glide.load.model.MultiModelLoaderFactory import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target import com.bumptech.glide.signature.ObjectKey -import com.pitchedapps.frost.facebook.FB_IMAGE_ID_MATCHER -import com.pitchedapps.frost.facebook.FB_URL_BASE -import com.pitchedapps.frost.facebook.get +import com.pitchedapps.frost.facebook.* +import io.reactivex.Maybe import okhttp3.Call import okhttp3.Request import java.io.IOException @@ -27,6 +26,18 @@ fun RequestAuth.getFullSizedImage(fbid: Long) = frostRequest(::getJsonUrl) { get() } +val test: () -> InputStream? = { null } + +/** + * Attempts to get the fbcdn url of the supplied image redirect url + */ +fun String.getFullSizedImageUrl(url: String): Maybe<String?> = Maybe.fromCallable { + val redirect = requestBuilder().url(url).get().call() + .execute().body()?.string() ?: return@fromCallable null + return@fromCallable FB_REDIRECT_URL_MATCHER.find(redirect)[1]?.formattedFbUrl + ?: return@fromCallable null +}.onErrorComplete() + /** * Request loader for a potentially hd version of a url * In this case, each url may potentially return an id, |