update 服务器接口测试
This commit is contained in:
@@ -29,6 +29,8 @@ object Constant {
|
|||||||
|
|
||||||
fun getCheckUpdateUrl() = "${getBaseUrl()}/appUpdate/checkUpdate"
|
fun getCheckUpdateUrl() = "${getBaseUrl()}/appUpdate/checkUpdate"
|
||||||
|
|
||||||
|
fun getTestUrl() = "${getBaseUrl()}/test"
|
||||||
|
|
||||||
private fun getBaseUrl() = host.replace("wss", "https").replace("ws", "http")
|
private fun getBaseUrl() = host.replace("wss", "https").replace("ws", "http")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import android.content.*
|
|||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.yameida.worktool.utils.HostTestHelper
|
||||||
import org.yameida.worktool.utils.PermissionHelper
|
import org.yameida.worktool.utils.PermissionHelper
|
||||||
import org.yameida.worktool.utils.PermissionPageManagement
|
import org.yameida.worktool.utils.PermissionPageManagement
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ class ListenActivity : AppCompatActivity() {
|
|||||||
if (text.matches("ws{1,2}://[^/]+.*".toRegex())) {
|
if (text.matches("ws{1,2}://[^/]+.*".toRegex())) {
|
||||||
Constant.host = text
|
Constant.host = text
|
||||||
tv_host.text = text
|
tv_host.text = text
|
||||||
ToastUtils.showLong("保存成功")
|
HostTestHelper.test()
|
||||||
commentDialog.dismiss()
|
commentDialog.dismiss()
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showLong("格式异常!")
|
ToastUtils.showLong("格式异常!")
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.yameida.worktool.utils
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.LogUtils
|
||||||
|
import com.blankj.utilcode.util.ToastUtils
|
||||||
|
import com.lzy.okgo.OkGo
|
||||||
|
import com.lzy.okgo.callback.StringCallback
|
||||||
|
import com.lzy.okgo.model.Response
|
||||||
|
import org.yameida.worktool.Constant
|
||||||
|
|
||||||
|
object HostTestHelper {
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
OkGo.get<String>(Constant.getTestUrl())
|
||||||
|
.execute(object : StringCallback() {
|
||||||
|
override fun onSuccess(response: Response<String>) {
|
||||||
|
LogUtils.i("测试接口: " + response.body())
|
||||||
|
ToastUtils.showLong("服务器连接测试成功!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(response: Response<String>) {
|
||||||
|
LogUtils.e("服务器连接测试失败")
|
||||||
|
ToastUtils.showLong("服务器连接测试失败!" + response.exception)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user