diff --git a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
index 980950b..ebdfd81 100644
--- a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
+++ b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
@@ -22,7 +22,6 @@
import com.casic.br.operationsite.utils.LocaleConstant
import com.casic.br.operationsite.utils.OnTcpConnectStateListener
import com.casic.br.operationsite.utils.TcpClient
-import com.pengxh.kt.lite.extensions.show
import com.pengxh.kt.lite.extensions.toAsciiCode
import com.pengxh.kt.lite.utils.SaveKeyValues
import com.pengxh.kt.lite.utils.WeakReferenceHandler
@@ -49,7 +48,7 @@
override fun handleMessage(msg: Message): Boolean {
when (msg.what) {
- LocaleConstant.CONNECT_TCP_CODE->{
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
index 980950b..ebdfd81 100644
--- a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
+++ b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
@@ -22,7 +22,6 @@
import com.casic.br.operationsite.utils.LocaleConstant
import com.casic.br.operationsite.utils.OnTcpConnectStateListener
import com.casic.br.operationsite.utils.TcpClient
-import com.pengxh.kt.lite.extensions.show
import com.pengxh.kt.lite.extensions.toAsciiCode
import com.pengxh.kt.lite.utils.SaveKeyValues
import com.pengxh.kt.lite.utils.WeakReferenceHandler
@@ -49,7 +48,7 @@
override fun handleMessage(msg: Message): Boolean {
when (msg.what) {
- LocaleConstant.CONNECT_TCP_CODE->{
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
index 00ce86a..4beeb21 100644
--- a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
+++ b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
@@ -33,7 +33,7 @@
companion object {
private const val INITIAL_IDLE_TIME = 15L
private const val MAX_RETRY_TIMES = 10
- private const val RECONNECT_DELAY_SECONDS = 15L
+ private const val RECONNECT_DELAY_SECONDS = 15 * 1000L
private const val RECEIVE_BUFFER_MIN = 5000
private const val RECEIVE_BUFFER_MAX = 8000
}
@@ -77,6 +77,9 @@
override fun channelActive(ctx: ChannelHandlerContext) {
val address = ctx.channel().remoteAddress() as InetSocketAddress
Log.d(kTag, "${address.address.hostAddress} 已连接")
+ scope.launch(Dispatchers.Main) {
+ "通讯服务已连接".show(BaseApplication.get())
+ }
listener.onConnected()
}
@@ -161,7 +164,7 @@
}
//使用协程延迟重连,替代 Netty 的 loopGroup.schedule,防止调度器滥用。
scope.launch(Dispatchers.Main) {
- delay(RECONNECT_DELAY_SECONDS * 1000L)
+ delay(RECONNECT_DELAY_SECONDS)
connect()
}
} else {
diff --git a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
index 980950b..ebdfd81 100644
--- a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
+++ b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
@@ -22,7 +22,6 @@
import com.casic.br.operationsite.utils.LocaleConstant
import com.casic.br.operationsite.utils.OnTcpConnectStateListener
import com.casic.br.operationsite.utils.TcpClient
-import com.pengxh.kt.lite.extensions.show
import com.pengxh.kt.lite.extensions.toAsciiCode
import com.pengxh.kt.lite.utils.SaveKeyValues
import com.pengxh.kt.lite.utils.WeakReferenceHandler
@@ -49,7 +48,7 @@
override fun handleMessage(msg: Message): Boolean {
when (msg.what) {
- LocaleConstant.CONNECT_TCP_CODE->{
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
index 00ce86a..4beeb21 100644
--- a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
+++ b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
@@ -33,7 +33,7 @@
companion object {
private const val INITIAL_IDLE_TIME = 15L
private const val MAX_RETRY_TIMES = 10
- private const val RECONNECT_DELAY_SECONDS = 15L
+ private const val RECONNECT_DELAY_SECONDS = 15 * 1000L
private const val RECEIVE_BUFFER_MIN = 5000
private const val RECEIVE_BUFFER_MAX = 8000
}
@@ -77,6 +77,9 @@
override fun channelActive(ctx: ChannelHandlerContext) {
val address = ctx.channel().remoteAddress() as InetSocketAddress
Log.d(kTag, "${address.address.hostAddress} 已连接")
+ scope.launch(Dispatchers.Main) {
+ "通讯服务已连接".show(BaseApplication.get())
+ }
listener.onConnected()
}
@@ -161,7 +164,7 @@
}
//使用协程延迟重连,替代 Netty 的 loopGroup.schedule,防止调度器滥用。
scope.launch(Dispatchers.Main) {
- delay(RECONNECT_DELAY_SECONDS * 1000L)
+ delay(RECONNECT_DELAY_SECONDS)
connect()
}
} else {
diff --git a/app/src/main/res/layout/activity_site_tab.xml b/app/src/main/res/layout/activity_site_tab.xml
index f00053e..6b7cc0b 100644
--- a/app/src/main/res/layout/activity_site_tab.xml
+++ b/app/src/main/res/layout/activity_site_tab.xml
@@ -313,7 +313,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
- android:padding="0dp"
android:text="报警信息" />
diff --git a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
index 980950b..ebdfd81 100644
--- a/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
+++ b/app/src/main/java/com/casic/br/operationsite/service/SocketConnectionService.kt
@@ -22,7 +22,6 @@
import com.casic.br.operationsite.utils.LocaleConstant
import com.casic.br.operationsite.utils.OnTcpConnectStateListener
import com.casic.br.operationsite.utils.TcpClient
-import com.pengxh.kt.lite.extensions.show
import com.pengxh.kt.lite.extensions.toAsciiCode
import com.pengxh.kt.lite.utils.SaveKeyValues
import com.pengxh.kt.lite.utils.WeakReferenceHandler
@@ -49,7 +48,7 @@
override fun handleMessage(msg: Message): Boolean {
when (msg.what) {
- LocaleConstant.CONNECT_TCP_CODE->{
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
index 00ce86a..4beeb21 100644
--- a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
+++ b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
@@ -33,7 +33,7 @@
companion object {
private const val INITIAL_IDLE_TIME = 15L
private const val MAX_RETRY_TIMES = 10
- private const val RECONNECT_DELAY_SECONDS = 15L
+ private const val RECONNECT_DELAY_SECONDS = 15 * 1000L
private const val RECEIVE_BUFFER_MIN = 5000
private const val RECEIVE_BUFFER_MAX = 8000
}
@@ -77,6 +77,9 @@
override fun channelActive(ctx: ChannelHandlerContext) {
val address = ctx.channel().remoteAddress() as InetSocketAddress
Log.d(kTag, "${address.address.hostAddress} 已连接")
+ scope.launch(Dispatchers.Main) {
+ "通讯服务已连接".show(BaseApplication.get())
+ }
listener.onConnected()
}
@@ -161,7 +164,7 @@
}
//使用协程延迟重连,替代 Netty 的 loopGroup.schedule,防止调度器滥用。
scope.launch(Dispatchers.Main) {
- delay(RECONNECT_DELAY_SECONDS * 1000L)
+ delay(RECONNECT_DELAY_SECONDS)
connect()
}
} else {
diff --git a/app/src/main/res/layout/activity_site_tab.xml b/app/src/main/res/layout/activity_site_tab.xml
index f00053e..6b7cc0b 100644
--- a/app/src/main/res/layout/activity_site_tab.xml
+++ b/app/src/main/res/layout/activity_site_tab.xml
@@ -313,7 +313,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
- android:padding="0dp"
android:text="报警信息" />
diff --git a/app/src/main/res/layout/fragment_base_settings.xml b/app/src/main/res/layout/fragment_base_settings.xml
index 9e875ae..fe2bac1 100644
--- a/app/src/main/res/layout/fragment_base_settings.xml
+++ b/app/src/main/res/layout/fragment_base_settings.xml
@@ -211,7 +211,7 @@
-
- {
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
index 00ce86a..4beeb21 100644
--- a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
+++ b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
@@ -33,7 +33,7 @@
companion object {
private const val INITIAL_IDLE_TIME = 15L
private const val MAX_RETRY_TIMES = 10
- private const val RECONNECT_DELAY_SECONDS = 15L
+ private const val RECONNECT_DELAY_SECONDS = 15 * 1000L
private const val RECEIVE_BUFFER_MIN = 5000
private const val RECEIVE_BUFFER_MAX = 8000
}
@@ -77,6 +77,9 @@
override fun channelActive(ctx: ChannelHandlerContext) {
val address = ctx.channel().remoteAddress() as InetSocketAddress
Log.d(kTag, "${address.address.hostAddress} 已连接")
+ scope.launch(Dispatchers.Main) {
+ "通讯服务已连接".show(BaseApplication.get())
+ }
listener.onConnected()
}
@@ -161,7 +164,7 @@
}
//使用协程延迟重连,替代 Netty 的 loopGroup.schedule,防止调度器滥用。
scope.launch(Dispatchers.Main) {
- delay(RECONNECT_DELAY_SECONDS * 1000L)
+ delay(RECONNECT_DELAY_SECONDS)
connect()
}
} else {
diff --git a/app/src/main/res/layout/activity_site_tab.xml b/app/src/main/res/layout/activity_site_tab.xml
index f00053e..6b7cc0b 100644
--- a/app/src/main/res/layout/activity_site_tab.xml
+++ b/app/src/main/res/layout/activity_site_tab.xml
@@ -313,7 +313,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
- android:padding="0dp"
android:text="报警信息" />
diff --git a/app/src/main/res/layout/fragment_base_settings.xml b/app/src/main/res/layout/fragment_base_settings.xml
index 9e875ae..fe2bac1 100644
--- a/app/src/main/res/layout/fragment_base_settings.xml
+++ b/app/src/main/res/layout/fragment_base_settings.xml
@@ -211,7 +211,7 @@
-
-
-
@@ -34,7 +34,7 @@
android:textColor="@color/mainThemeColor"
android:textSize="@dimen/sp_16" />
- {
+ LocaleConstant.CONNECT_TCP_CODE -> {
tcpClient.start()
}
@@ -214,7 +213,6 @@
notificationBuilder?.setContentTitle("通讯服务已连接")
val notification = notificationBuilder?.build()
notificationManager.notify(notificationId, notification)
- "通讯服务已连接".show(this)
//定时查询甲烷浓度
weakReferenceHandler?.post(methaneRunnable)
}
diff --git a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
index 00ce86a..4beeb21 100644
--- a/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
+++ b/app/src/main/java/com/casic/br/operationsite/utils/TcpClient.kt
@@ -33,7 +33,7 @@
companion object {
private const val INITIAL_IDLE_TIME = 15L
private const val MAX_RETRY_TIMES = 10
- private const val RECONNECT_DELAY_SECONDS = 15L
+ private const val RECONNECT_DELAY_SECONDS = 15 * 1000L
private const val RECEIVE_BUFFER_MIN = 5000
private const val RECEIVE_BUFFER_MAX = 8000
}
@@ -77,6 +77,9 @@
override fun channelActive(ctx: ChannelHandlerContext) {
val address = ctx.channel().remoteAddress() as InetSocketAddress
Log.d(kTag, "${address.address.hostAddress} 已连接")
+ scope.launch(Dispatchers.Main) {
+ "通讯服务已连接".show(BaseApplication.get())
+ }
listener.onConnected()
}
@@ -161,7 +164,7 @@
}
//使用协程延迟重连,替代 Netty 的 loopGroup.schedule,防止调度器滥用。
scope.launch(Dispatchers.Main) {
- delay(RECONNECT_DELAY_SECONDS * 1000L)
+ delay(RECONNECT_DELAY_SECONDS)
connect()
}
} else {
diff --git a/app/src/main/res/layout/activity_site_tab.xml b/app/src/main/res/layout/activity_site_tab.xml
index f00053e..6b7cc0b 100644
--- a/app/src/main/res/layout/activity_site_tab.xml
+++ b/app/src/main/res/layout/activity_site_tab.xml
@@ -313,7 +313,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
- android:padding="0dp"
android:text="报警信息" />
diff --git a/app/src/main/res/layout/fragment_base_settings.xml b/app/src/main/res/layout/fragment_base_settings.xml
index 9e875ae..fe2bac1 100644
--- a/app/src/main/res/layout/fragment_base_settings.xml
+++ b/app/src/main/res/layout/fragment_base_settings.xml
@@ -211,7 +211,7 @@
-
-
-
@@ -34,7 +34,7 @@
android:textColor="@color/mainThemeColor"
android:textSize="@dimen/sp_16" />
-
-
-