aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/facebook
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt52
2 files changed, 34 insertions, 33 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 4e932d09..ea1b0946 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -28,29 +28,28 @@ import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.cookies
import com.pitchedapps.frost.utils.launchLogin
-import kotlin.coroutines.resume
-import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.withContext
-import org.koin.dsl.module
+import javax.inject.Inject
+import kotlin.coroutines.resume
+import kotlin.coroutines.suspendCoroutine
/**
* Created by Allan Wang on 2017-05-30.
*
* The following component manages all cookie transfers.
*/
-class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) {
+class FbCookie @Inject internal constructor(
+ private val prefs: Prefs,
+ private val cookieDao: CookieDao
+) {
companion object {
private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM
private const val MESSENGER_COOKIE_DOMAIN = HTTPS_MESSENGER_COM
-
- fun module() = module {
- single { FbCookie(get(), get()) }
- }
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt
index 68c629a9..0c9a7e92 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt
@@ -90,31 +90,33 @@ private class SearchParserImpl : FrostParserBase<FrostSearches>(false) {
?: doc.getElementById("root")
?: return null
- return FrostSearches(container.select("table[role=presentation]").mapNotNull { el ->
- // Our assumption is that search entries start with an image, followed by general info
- // There may be other <td />s, but we will not be parsing them
- // Furthermore, the <td /> entry wraps a link, containing all the necessary info
- val a = el.select("td")
- .getOrNull(1)
- ?.selectFirst("a")
- ?: return@mapNotNull null
- val url =
- a.attr("href").takeIf { it.isNotEmpty() }
- ?.formattedFbUrl?.formattedSearchUrl
+ return FrostSearches(
+ container.select("table[role=presentation]").mapNotNull { el ->
+ // Our assumption is that search entries start with an image, followed by general info
+ // There may be other <td />s, but we will not be parsing them
+ // Furthermore, the <td /> entry wraps a link, containing all the necessary info
+ val a = el.select("td")
+ .getOrNull(1)
+ ?.selectFirst("a")
?: return@mapNotNull null
- // Currently, children should all be <div /> elements, where the first entry is the name/title
- // And the other entries are additional info.
- // There are also cases of nested tables, eg for the "join" button in groups.
- // Those elements have <span /> texts, so we will filter by div to ignore those
- val texts = a.children().filter { it.tagName() == "div" && it.hasText() }
- val title = texts.firstOrNull()?.text() ?: return@mapNotNull null
- val info = texts.takeIf { it.size > 1 }?.last()?.text()
- L.e { a }
- create(
- href = url,
- title = title,
- description = info
- ).also { L.e { it } }
- })
+ val url =
+ a.attr("href").takeIf { it.isNotEmpty() }
+ ?.formattedFbUrl?.formattedSearchUrl
+ ?: return@mapNotNull null
+ // Currently, children should all be <div /> elements, where the first entry is the name/title
+ // And the other entries are additional info.
+ // There are also cases of nested tables, eg for the "join" button in groups.
+ // Those elements have <span /> texts, so we will filter by div to ignore those
+ val texts = a.children().filter { it.tagName() == "div" && it.hasText() }
+ val title = texts.firstOrNull()?.text() ?: return@mapNotNull null
+ val info = texts.takeIf { it.size > 1 }?.last()?.text()
+ L.e { a }
+ create(
+ href = url,
+ title = title,
+ description = info
+ ).also { L.e { it } }
+ }
+ )
}
}