aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt20
2 files changed, 16 insertions, 19 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
index c7931e53..627b0186 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -60,13 +60,13 @@ object FbCookie {
val cookies = cookie.split(";").map { Pair(it, SingleSubject.create<Boolean>()) }
cookies.forEach { (cookie, callback) -> setCookie(COOKIE_DOMAIN, cookie) { callback.onSuccess(it) } }
Observable.zip<Boolean, Unit>(cookies.map { (_, callback) -> callback.toObservable() }) {}
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe {
- callback?.invoke()
- L.d { "Cookies set" }
- L._d { cookie }
- flush()
- }
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe {
+ callback?.invoke()
+ L.d { "Cookies set" }
+ L._d { cookie }
+ flush()
+ }
}
}
@@ -97,7 +97,6 @@ object FbCookie {
}
}
-
operator fun invoke() {
L.d { "FbCookie Invoke User" }
val manager = CookieManager.getInstance()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index 392cb353..2fe78f02 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -39,8 +39,6 @@ import com.pitchedapps.frost.injectors.jsInject
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.isFacebookUrl
-import org.jetbrains.anko.doAsync
-import org.jetbrains.anko.uiThread
/**
* Created by Allan Wang on 2017-05-29.
@@ -76,18 +74,18 @@ class LoginWebView @JvmOverloads constructor(
override fun onPageFinished(view: WebView, url: String?) {
super.onPageFinished(view, url)
- checkForLogin(url) { id, cookie -> loginCallback(CookieModel(id, "", cookie)) }
+ val cookieModel = checkForLogin(url)
+ if (cookieModel != null)
+ loginCallback(cookieModel)
if (!view.isVisible) view.fadeIn()
}
- fun checkForLogin(url: String?, onFound: (id: Long, cookie: String) -> Unit) {
- doAsync {
- if (!url.isFacebookUrl) return@doAsync
- val cookie = CookieManager.getInstance().getCookie(url) ?: return@doAsync
- L.d { "Checking cookie for login" }
- val id = FB_USER_MATCHER.find(cookie)[1]?.toLong() ?: return@doAsync
- uiThread { onFound(id, cookie) }
- }
+ fun checkForLogin(url: String?): CookieModel? {
+ if (!url.isFacebookUrl) return null
+ val cookie = CookieManager.getInstance().getCookie(url) ?: return null
+ L.d { "Checking cookie for login" }
+ val id = FB_USER_MATCHER.find(cookie)[1]?.toLong() ?: return null
+ return CookieModel(id, "", cookie)
}
override fun onPageCommitVisible(view: WebView, url: String?) {