now handling unexpected ws close
This commit is contained in:
parent
988272070d
commit
e5772bcad3
|
@ -190,6 +190,7 @@ fun isInternetConnectionAvailable(context: Context): Boolean {
|
|||
}
|
||||
|
||||
fun noInternetConnectionAvailableNotification(context: Context) {
|
||||
(context as Activity).runOnUiThread {
|
||||
AlertDialog.Builder(context)
|
||||
.setMessage(context.getString(R.string.no_internet_connection))
|
||||
.setPositiveButton(R.string.quit) { _, _ ->
|
||||
|
@ -210,4 +211,5 @@ fun noInternetConnectionAvailableNotification(context: Context) {
|
|||
sharedPreferences.edit().putString("currentGroup", "").apply()
|
||||
exitProcess(0)
|
||||
}.show()
|
||||
}
|
||||
}
|
|
@ -139,10 +139,12 @@ class WebSocketClient(private val context: Context, private val server: String)
|
|||
|
||||
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
|
||||
Log.d("QWERTYUIOP", "Closing ws. Reason: $reason")
|
||||
noInternetConnectionAvailableNotification(context)
|
||||
}
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
|
||||
Log.d("QWERTYUIOP","Connection failed: ${t.message}")
|
||||
noInternetConnectionAvailableNotification(context)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
android:ems="10"
|
||||
android:id="@+id/barcodeTextEdit" app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="8dp" android:hint="Barcode" android:textColorHint="#737373"
|
||||
android:layout_marginTop="8dp" android:hint="@string/barcode" android:textColorHint="#737373"
|
||||
android:layout_marginStart="5dp"/>
|
||||
<CheckBox
|
||||
android:text="@string/no_barcode"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#141218">
|
||||
>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -114,10 +114,10 @@
|
|||
<string name="image_compress_factor">Степень сжатия изображения</string>
|
||||
<string name="current_group">Текущая группа</string>
|
||||
<string name="cancel">Отмена</string>
|
||||
<string name="no_internet_connection">No internet connection available. Please, connect to a network.</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="logout">Log out</string>
|
||||
<string name="online_only_feature">This feature is online only</string>
|
||||
<string name="no_internet_connection">Не могу установить соединение с сервером. Возможно, вы отключены от сети?</string>
|
||||
<string name="ok">Ок</string>
|
||||
<string name="logout">Выйти</string>
|
||||
<string name="online_only_feature">Эта возможность доступна только с онлайн аккаунтом</string>
|
||||
<string-array name="languages">
|
||||
<item>en-US</item>
|
||||
<item>ru-RU</item>
|
||||
|
|
|
@ -112,8 +112,8 @@
|
|||
<string name="image_compress_factor">Image compression factor</string>
|
||||
<string name="current_group">Current group</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="no_internet_connection">No internet connection available. Please, connect to a network.</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="no_internet_connection">Cannot reach the server. Maybe, you lost internet connection?</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="logout">Log out</string>
|
||||
<string name="online_only_feature">This feature is online only</string>
|
||||
<string-array name="languages">
|
||||
|
|
Loading…
Reference in New Issue