diff options
author | Allan Wang <me@allanwang.ca> | 2019-08-06 00:49:58 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-08-06 00:49:58 -0700 |
commit | 55bf3e4b5b4af5baa3c230ca82f74988608971a3 (patch) | |
tree | 3db856e037b70257aaef19e34db6b0856bda6412 /app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers | |
parent | 99953f087f2c363dad05ae3f86b5bcba22484e43 (diff) | |
download | frost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.tar.gz frost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.tar.bz2 frost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.zip |
Format kotlin
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers')
3 files changed, 12 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt index 6af21259..1240614b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt @@ -99,7 +99,8 @@ internal fun <T> List<T>.toJsonString(tag: String, indent: Int) = StringBuilder( * T should have a readable toString() function * [redirectToText] dictates whether all data should be converted to text then back to document before parsing */ -internal abstract class FrostParserBase<out T : ParseData>(private val redirectToText: Boolean) : FrostParser<T> { +internal abstract class FrostParserBase<out T : ParseData>(private val redirectToText: Boolean) : + FrostParser<T> { final override fun parse(cookie: String?) = parseFromUrl(cookie, url) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt index 00a1432f..3705448a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt @@ -38,7 +38,8 @@ import org.jsoup.nodes.Element */ object MessageParser : FrostParser<FrostMessages> by MessageParserImpl() { - fun queryUser(cookie: String?, name: String) = parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=$name") + fun queryUser(cookie: String?, name: String) = + parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=$name") } data class FrostMessages( @@ -120,7 +121,10 @@ private class MessageParserImpl : FrostParserBase<FrostMessages>(true) { override fun parseImpl(doc: Document): FrostMessages? { val threadList = doc.getElementById("threadlist_rows") ?: return null val threads: List<FrostThread> = - threadList.getElementsByAttributeValueMatching("id", ".*${FB_MESSAGE_NOTIF_ID_MATCHER.pattern}.*") + threadList.getElementsByAttributeValueMatching( + "id", + ".*${FB_MESSAGE_NOTIF_ID_MATCHER.pattern}.*" + ) .mapNotNull(this::parseMessage) val seeMore = parseLink(doc.getElementById("see_older_threads")) val extraLinks = threadList.nextElementSibling().select("a") diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt index faeaa27c..f9db0a8f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt @@ -96,7 +96,8 @@ private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) { val notifications = notificationList .getElementsByAttributeValueMatching("id", ".*${FB_NOTIF_ID_MATCHER.pattern}.*") .mapNotNull(this::parseNotif) - val seeMore = parseLink(doc.getElementsByAttributeValue("href", "/notifications.php?more").first()) + val seeMore = + parseLink(doc.getElementsByAttributeValue("href", "/notifications.php?more").first()) return FrostNotifs(notifications, seeMore) } @@ -109,7 +110,8 @@ private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) { ?: System.currentTimeMillis() % FALLBACK_TIME_MOD val img = element.getInnerImgStyle() val timeString = abbr.text() - val content = a.text().replace("\u00a0", " ").removeSuffix(timeString).trim() //remove + val content = + a.text().replace("\u00a0", " ").removeSuffix(timeString).trim() //remove val thumbnail = element.selectFirst("img.thumbnail")?.attr("src") return FrostNotif( id = id, |