aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/traccar
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-04 14:11:43 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-04 14:11:43 -0600
commit6de89cb5f5ef0269e349c1496b0a6ede839e0934 (patch)
tree9daf1db391772a65f3a56d8577abb938841704cc /app/src/main/java/org/traccar
parentc95542f9b2ea1c0b9100daecb60a74ac949d32b3 (diff)
downloadetbsa-traccar-manager-android-6de89cb5f5ef0269e349c1496b0a6ede839e0934.tar.gz
etbsa-traccar-manager-android-6de89cb5f5ef0269e349c1496b0a6ede839e0934.tar.bz2
etbsa-traccar-manager-android-6de89cb5f5ef0269e349c1496b0a6ede839e0934.zip
Fixed NullPointerException for cookies
Diffstat (limited to 'app/src/main/java/org/traccar')
-rw-r--r--app/src/main/java/org/traccar/manager/MainFragment.kt27
1 files changed, 14 insertions, 13 deletions
diff --git a/app/src/main/java/org/traccar/manager/MainFragment.kt b/app/src/main/java/org/traccar/manager/MainFragment.kt
index ecb93e3..981f3d9 100644
--- a/app/src/main/java/org/traccar/manager/MainFragment.kt
+++ b/app/src/main/java/org/traccar/manager/MainFragment.kt
@@ -54,19 +54,20 @@ class MainFragment : WebViewFragment() {
CookieManager.getInstance().flush()
}
- val cookies = CookieManager.getInstance().getCookie(url)
- if (cookies.contains("JSESSIONID") && !tokenSet) {
- // Register token on server
- if (PreferenceManager.getDefaultSharedPreferences(activity)
- .contains(MainActivity.PREFERENCE_TOKEN)
- ) {
- val token = PreferenceManager.getDefaultSharedPreferences(activity)
- .getString(MainActivity.PREFERENCE_TOKEN, "")
- val code = "updateNotificationToken && updateNotificationToken('$token')"
- Log.d("MainFragment", code)
- Toast.makeText(activity, code, Toast.LENGTH_LONG).show()
- webView.evaluateJavascript(code, null)
- tokenSet = true
+ CookieManager.getInstance().getCookie(url)?.let {
+ if (it.contains("JSESSIONID") && !tokenSet) {
+ // Register token on server
+ if (PreferenceManager.getDefaultSharedPreferences(activity)
+ .contains(MainActivity.PREFERENCE_TOKEN)
+ ) {
+ val token = PreferenceManager.getDefaultSharedPreferences(activity)
+ .getString(MainActivity.PREFERENCE_TOKEN, "")
+ val code = "updateNotificationToken && updateNotificationToken('$token')"
+ Log.d("MainFragment", code)
+ Toast.makeText(activity, code, Toast.LENGTH_LONG).show()
+ webView.evaluateJavascript(code, null)
+ tokenSet = true
+ }
}
}
}