aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/dbflow
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-26 14:56:44 -0400
committerGitHub <noreply@github.com>2018-09-26 14:56:44 -0400
commit438affb07ae106e490884fafa3c2dd825e7649a4 (patch)
treeb94e182bf4d083af049120a6b5f94f82c4595318 /app/src/main/kotlin/com/pitchedapps/frost/dbflow
parentc5e769deabeb80d7257b85c5c3d802cf46e6b191 (diff)
downloadfrost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.gz
frost-438affb07ae106e490884fafa3c2dd825e7649a4.tar.bz2
frost-438affb07ae106e490884fafa3c2dd825e7649a4.zip
Cleanup (#1087)
* Feature/download manager (#855) * Add initial github release check * Create update service * Clean old manager directory * Update kau * Update updateActivity snippet * Add back gradle keys * Remove update service functionality * Update changelog * Misc (#865) * Clean up git code * Update download link * Update theme * Reorder settings, resolvees #856 * Do not log undeliverable exception * Handle potential lack of webview * Set notification epoch default to now, resolves #857 * Fix notification epoch time init * Update changelog * Update theme * Add slack url, resolves #880 * Prepare for image update * Fix view full image (#882) * Test including full photo viewer * Test cookie in glide * Fix parser and add redirects to view full image * Update changelog * Fix compilation and add new keys * Update all versions * Fix signing configs * Fix exoplayer api update * Change string usage * Test scss on travis * Test with node_js flag * Add back css * Update versions and fix video view
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/dbflow')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt42
1 files changed, 21 insertions, 21 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
index 69cf32b7..1fe65d5a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
@@ -13,6 +13,7 @@ import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import com.raizlabs.android.dbflow.kotlinextensions.*
import com.raizlabs.android.dbflow.structure.BaseModel
+import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import paperparcel.PaperParcel
import java.net.UnknownHostException
@@ -67,26 +68,25 @@ fun removeCookie(id: Long) {
}
}
-inline fun CookieModel.fetchUsername(crossinline callback: (String) -> Unit) {
- ReactiveNetwork.checkInternetConnectivity().subscribeOn(Schedulers.io()).subscribe { yes, _ ->
- if (!yes) return@subscribe callback("")
- var result = ""
- try {
- result = frostJsoup(cookie, FbItem.PROFILE.url).title()
- L.d { "Fetch username found" }
- } catch (e: Exception) {
- if (e !is UnknownHostException)
- e.logFrostEvent("Fetch username failed")
- } finally {
- if (result.isBlank() && (name?.isNotBlank() == true)) {
- callback(name!!)
- return@subscribe
+inline fun CookieModel.fetchUsername(crossinline callback: (String) -> Unit): Disposable =
+ ReactiveNetwork.checkInternetConnectivity().subscribeOn(Schedulers.io()).subscribe { yes, _ ->
+ if (!yes) return@subscribe callback("")
+ var result = ""
+ try {
+ result = frostJsoup(cookie, FbItem.PROFILE.url).title()
+ L.d { "Fetch username found" }
+ } catch (e: Exception) {
+ if (e !is UnknownHostException)
+ e.logFrostEvent("Fetch username failed")
+ } finally {
+ if (result.isBlank() && (name?.isNotBlank() == true)) {
+ callback(name!!)
+ return@subscribe
+ }
+ if (name != result) {
+ name = result
+ saveFbCookie(this@fetchUsername)
+ }
+ callback(result)
}
- if (name != result) {
- name = result
- saveFbCookie(this@fetchUsername)
- }
- callback(result)
}
- }
-} \ No newline at end of file