GoogleFragment: Don't attempt to parse cookies if they are null

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-07-22 00:37:31 +05:30
parent 9bff289e0a
commit 14fc673b64

View File

@@ -90,6 +90,8 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
webViewClient = object : WebViewClient() { webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) { override fun onPageFinished(view: WebView, url: String) {
val cookies = CookieManager.getInstance().getCookie(url) val cookies = CookieManager.getInstance().getCookie(url)
// cookies can be null if there is an error
if (cookies != null) {
val cookieMap = AC2DMUtil.parseCookieString(cookies) val cookieMap = AC2DMUtil.parseCookieString(cookies)
if (cookieMap.isNotEmpty() && cookieMap[AUTH_TOKEN] != null) { if (cookieMap.isNotEmpty() && cookieMap[AUTH_TOKEN] != null) {
val oauthToken = cookieMap[AUTH_TOKEN] val oauthToken = cookieMap[AUTH_TOKEN]
@@ -100,6 +102,7 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
} }
} }
} }
}
settings.apply { settings.apply {
allowContentAccess = true allowContentAccess = true