aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-26 19:58:16 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-26 19:58:16 -0700
commitd306bd42105bdb613f7760a89cd576c24c848da2 (patch)
tree296a58758a24106290aea2399913d50c2b96438b
parent8c945d554d172f8034bbb68ad7b3cb40590c7b83 (diff)
downloadetbsa-traccar-manager-android-d306bd42105bdb613f7760a89cd576c24c848da2.tar.gz
etbsa-traccar-manager-android-d306bd42105bdb613f7760a89cd576c24c848da2.tar.bz2
etbsa-traccar-manager-android-d306bd42105bdb613f7760a89cd576c24c848da2.zip
Handle empty URL
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/org/traccar/manager/MainFragment.kt8
-rw-r--r--app/src/main/java/org/traccar/manager/StartFragment.kt1
3 files changed, 9 insertions, 4 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 2a1dd91..1a17eab 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId 'org.traccar.manager'
minSdkVersion 19
targetSdkVersion 30
- versionCode 26
- versionName '2.15'
+ versionCode 27
+ versionName '2.16'
}
compileOptions {
diff --git a/app/src/main/java/org/traccar/manager/MainFragment.kt b/app/src/main/java/org/traccar/manager/MainFragment.kt
index 2675d0c..3f09e56 100644
--- a/app/src/main/java/org/traccar/manager/MainFragment.kt
+++ b/app/src/main/java/org/traccar/manager/MainFragment.kt
@@ -77,7 +77,13 @@ class MainFragment : WebViewFragment() {
webSettings.mediaPlaybackRequiresUserGesture = false
val url = PreferenceManager.getDefaultSharedPreferences(activity)
.getString(MainActivity.PREFERENCE_URL, null)
- url?.let { webView.loadUrl(it) }
+ if (url != null) {
+ webView.loadUrl(url)
+ } else {
+ activity.fragmentManager
+ .beginTransaction().replace(android.R.id.content, StartFragment())
+ .commitAllowingStateLoss()
+ }
}
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
diff --git a/app/src/main/java/org/traccar/manager/StartFragment.kt b/app/src/main/java/org/traccar/manager/StartFragment.kt
index ee379a2..536b22c 100644
--- a/app/src/main/java/org/traccar/manager/StartFragment.kt
+++ b/app/src/main/java/org/traccar/manager/StartFragment.kt
@@ -31,7 +31,6 @@ import android.widget.EditText
import androidx.preference.PreferenceManager
import org.json.JSONException
import org.json.JSONObject
-import org.traccar.manager.StartFragment
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader