diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-31 02:44:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-31 02:44:46 -0500 |
commit | 725d6a99a07f91f940a07e6b49dd6224a6aa32d1 (patch) | |
tree | 4e0b1b3b9ffe9b5aef3c8d0f154ea9ab1058fd5e /app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt | |
parent | 3076d9a97c203497aec1415d8ac6037d10eebb46 (diff) | |
download | frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.gz frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.bz2 frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.zip |
Enhancement/proguard (#589)
* Add error log
* Rewrite logger
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt | 20 |
1 files changed, 11 insertions, 9 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 6f08981c..ccb23b93 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -30,12 +30,13 @@ object FbCookie { callback?.invoke() return@removeAllCookies } - L.d("Setting cookie", cookie) + L.d { "Setting cookie" } val cookies = cookie.split(";").map { Pair(it, SingleSubject.create<Boolean>()) } cookies.forEach { (cookie, callback) -> setCookie(FB_URL_BASE, cookie, { callback.onSuccess(it) }) } Observable.zip<Boolean, Unit>(cookies.map { (_, callback) -> callback.toObservable() }, {}).subscribeOn(AndroidSchedulers.mainThread()).subscribe { callback?.invoke() - L.d("Cookies set", webCookie) + L.d { "Cookies set" } + L._d { cookie } flush() } } @@ -43,19 +44,19 @@ object FbCookie { } operator fun invoke() { - L.d("FbCookie Invoke User", Prefs.userId.toString()) + L.d { "FbCookie Invoke User" } with(CookieManager.getInstance()) { setAcceptCookie(true) } val dbCookie = loadFbCookie(Prefs.userId)?.cookie if (dbCookie != null && webCookie == null) { - L.d("DbCookie found & WebCookie is null; setting webcookie") + L.d { "DbCookie found & WebCookie is null; setting webcookie" } setWebCookie(dbCookie, null) } } fun save(id: Long) { - L.d("New cookie found", id.toString()) + L.d { "New cookie found" } Prefs.userId = id CookieManager.getInstance().flush() val cookie = CookieModel(Prefs.userId, "", webCookie) @@ -78,11 +79,11 @@ object FbCookie { fun switchUser(cookie: CookieModel?, callback: () -> Unit) { if (cookie == null) { - L.d("Switching User; null cookie") + L.d { "Switching User; null cookie" } callback() return } - L.d("Switching User", cookie.toString()) + L.d { "Switching User" } Prefs.userId = cookie.id setWebCookie(cookie.cookie, callback) } @@ -104,7 +105,7 @@ object FbCookie { * Clear the cookies of the given id */ fun logout(id: Long, callback: () -> Unit) { - L.d("Logging out user $id") + L.d { "Logging out user" } removeCookie(id) reset(callback) } @@ -119,7 +120,8 @@ object FbCookie { Prefs.prevId = -1L if (prevId != Prefs.userId) { switchUser(prevId) { - L.d("Switch back user", "${Prefs.userId} to ${prevId}") + L.d { "Switch back user" } + L._d { "${Prefs.userId} to $prevId" } callback() } } else callback() |