diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-28 21:41:38 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-28 21:41:38 -0500 |
commit | 66a6657b81e6274e1eac33c4c7379d3db2c463fb (patch) | |
tree | 8e6202efb768d954145038cb8642453c62650c5e /app/src | |
parent | 5393f171e4b489b90fa93df1b23288178d9daaef (diff) | |
download | frost-66a6657b81e6274e1eac33c4c7379d3db2c463fb.tar.gz frost-66a6657b81e6274e1eac33c4c7379d3db2c463fb.tar.bz2 frost-66a6657b81e6274e1eac33c4c7379d3db2c463fb.zip |
Prevent crash with null frost cookie
Diffstat (limited to 'app/src')
3 files changed, 11 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt index c03ac0e2..7a8309ff 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt @@ -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) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 56c1d6d9..8e4e410d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -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 { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 4611d27d..c8b54e7a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -102,6 +102,7 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun loadLogin() { + L.d { "Sign up button found; load login" } FbCookie.logout(context) } |