1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-12 14:03:00 +01:00

Prevent crash with null frost cookie

This commit is contained in:
Allan Wang 2018-12-28 21:41:38 -05:00
parent 5393f171e4
commit 66a6657b81
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
3 changed files with 11 additions and 2 deletions

View File

@ -53,6 +53,7 @@ abstract class RecyclerFragment<T, Item : IItem<*, *>> : BaseFragment(), Recycle
val data = try {
reloadImpl(progress)
} catch (e: Exception) {
L.e(e) { "Recycler reload fail" }
null
}
if (!isActive)

View File

@ -114,8 +114,10 @@ fun Activity.cookies(): ArrayList<CookieModel> {
private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlayImpl(url: String) {
val argUrl = url.formattedFbUrl
L.v { "Launch received: $url\nLaunch web overlay: $argUrl" }
if (argUrl.isFacebookUrl && argUrl.contains("/logout.php"))
if (argUrl.isFacebookUrl && argUrl.contains("/logout.php")) {
L.d { "Logout php found" }
FbCookie.logout(this)
}
else if (!(Prefs.linksInDefaultApp && resolveActivityForUri(Uri.parse(argUrl))))
startActivity<T>(false, intentBuilder = {
putExtra(ARG_URL, argUrl)
@ -371,7 +373,12 @@ fun EmailBuilder.addFrostDetails() {
fun frostJsoup(url: String) = frostJsoup(FbCookie.webCookie, url)
fun frostJsoup(cookie: String?, url: String) =
Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!!
Jsoup.connect(url).run {
if (cookie != null) cookie(
FACEBOOK_COM,
cookie
) else this
}.userAgent(USER_AGENT_BASIC).get()!!
fun Element.first(vararg select: String): Element? {
select.forEach {

View File

@ -102,6 +102,7 @@ class FrostJSI(val web: FrostWebView) {
@JavascriptInterface
fun loadLogin() {
L.d { "Sign up button found; load login" }
FbCookie.logout(context)
}