修复:无网络时主动控制·服务端界面自动获取IP异常
This commit is contained in:
parent
4e9921ef3c
commit
2f8b5d730b
|
@ -142,12 +142,10 @@ class ServerFragment : BaseFragment<FragmentServerBinding?>(), View.OnClickListe
|
|||
XToastUtils.info(getString(R.string.sign_key_tips))
|
||||
}
|
||||
R.id.tv_server_tips, R.id.iv_copy -> {
|
||||
if (inetAddress != null) {
|
||||
val url = "http://${inetAddress!!.hostAddress}:5000"
|
||||
val url = if (inetAddress != null) "http://${inetAddress?.hostAddress}:5000" else "http://127.0.0.1:5000"
|
||||
ClipboardUtils.copyText(url)
|
||||
XToastUtils.info(String.format(getString(R.string.copied_to_clipboard), url))
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@ -156,9 +154,15 @@ class ServerFragment : BaseFragment<FragmentServerBinding?>(), View.OnClickListe
|
|||
private fun refreshButtonText() {
|
||||
if (ServiceUtils.isServiceRunning("com.idormy.sms.forwarder.service.HttpService")) {
|
||||
binding!!.toggleServerBtn.text = resources.getText(R.string.stop_server)
|
||||
binding!!.ivCopy.visibility = View.VISIBLE
|
||||
try {
|
||||
inetAddress = NetworkUtils.getLocalInetAddress()
|
||||
binding!!.tvServerTips.text = getString(R.string.http_server_running, inetAddress!!.hostAddress, HTTP_SERVER_PORT)
|
||||
binding!!.ivCopy.visibility = View.VISIBLE
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
binding!!.tvServerTips.text = getString(R.string.http_server_running, "127.0.0.1", HTTP_SERVER_PORT)
|
||||
}
|
||||
} else {
|
||||
binding!!.toggleServerBtn.text = resources.getText(R.string.start_server)
|
||||
binding!!.tvServerTips.text = getString(R.string.http_server_stopped)
|
||||
|
|
Loading…
Reference in New Issue