Webソケットが切断された時にカラムヘッダの表示を更新する
This commit is contained in:
parent
74c3a0f358
commit
731780c775
|
@ -12,8 +12,8 @@ android {
|
|||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
|
||||
versionCode 240
|
||||
versionName "2.4.0"
|
||||
versionCode 241
|
||||
versionName "2.4.1"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// https://stackoverflow.com/questions/47791227/java-lang-illegalstateexception-dex-archives-setting-dex-extension-only-for
|
||||
|
|
|
@ -98,6 +98,16 @@ internal class StreamReader(
|
|||
return callback_list.contains(streamCallback)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun fireListeningChanged(){
|
||||
for(c in callback_list) {
|
||||
try{
|
||||
c.onListeningStateChanged()
|
||||
}catch(ex:Throwable){
|
||||
log.trace(ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Invoked when a web socket has been accepted by the remote peer and may begin transmitting
|
||||
* messages.
|
||||
|
@ -178,6 +188,7 @@ internal class StreamReader(
|
|||
bListening.set(false)
|
||||
handler.removeCallbacks(proc_reconnect)
|
||||
handler.postDelayed(proc_reconnect, 10000L)
|
||||
fireListeningChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,6 +205,7 @@ internal class StreamReader(
|
|||
bListening.set(false)
|
||||
handler.removeCallbacks(proc_reconnect)
|
||||
handler.postDelayed(proc_reconnect, 10000L)
|
||||
fireListeningChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,6 +218,7 @@ internal class StreamReader(
|
|||
|
||||
bListening.set(false)
|
||||
handler.removeCallbacks(proc_reconnect)
|
||||
fireListeningChanged()
|
||||
|
||||
if(ex is ProtocolException) {
|
||||
val msg = ex.message
|
||||
|
@ -215,6 +228,7 @@ internal class StreamReader(
|
|||
}
|
||||
}
|
||||
handler.postDelayed(proc_reconnect, 10000L)
|
||||
|
||||
}
|
||||
|
||||
internal fun startRead() {
|
||||
|
@ -227,12 +241,15 @@ internal class StreamReader(
|
|||
}
|
||||
|
||||
bListening.set(true)
|
||||
fireListeningChanged()
|
||||
|
||||
TootTaskRunner(context).run(access_info, object : TootTask {
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
val result = client.webSocket(end_point, this@Reader)
|
||||
if(result == null) {
|
||||
log.d("startRead: cancelled.")
|
||||
bListening.set(false)
|
||||
fireListeningChanged()
|
||||
} else {
|
||||
val ws = result.data as? WebSocket
|
||||
if(ws != null) {
|
||||
|
|
Loading…
Reference in New Issue