功能优化
This commit is contained in:
@@ -21,6 +21,8 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
object HttpUtil {
|
||||
|
||||
var loopGetToken = true
|
||||
|
||||
fun runMainThread(action: () -> Unit) {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
action()
|
||||
@@ -39,7 +41,7 @@ object HttpUtil {
|
||||
.apply {
|
||||
if (header != null) {
|
||||
header.forEach {
|
||||
addHeader(it.value, it.value)
|
||||
addHeader(it.key, it.value)
|
||||
}
|
||||
} else {
|
||||
val token = getToken()
|
||||
@@ -176,7 +178,8 @@ object HttpUtil {
|
||||
}
|
||||
if (baseReq.code != 200) {
|
||||
doFailure(baseReq.code, baseReq.message)
|
||||
if (baseReq.code == 500 || baseReq.code == 401) {
|
||||
//baseReq.code == 500 ||
|
||||
if (baseReq.code == 401 && loopGetToken) {
|
||||
exeTokenThread()
|
||||
}
|
||||
return@runCatching
|
||||
|
||||
@@ -43,14 +43,14 @@ class HomeActivity : BaseActivity() {
|
||||
binding = ActivityHomeBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setHeaderBackground(isHomePage = true)
|
||||
binding.radioGroup?.setOnCheckedChangeListener { group, checkedId ->
|
||||
binding.radioGroup.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == R.id.radioSw) {
|
||||
BaseApp.canteenId = "1678234139391512577"
|
||||
} else {
|
||||
BaseApp.canteenId = "0"
|
||||
}
|
||||
}
|
||||
binding.radioGroup?.check(R.id.radioZk)
|
||||
// binding.radioGroup.check(R.id.radioZk)
|
||||
initRecyclerView()
|
||||
// HttpUtil.getAppToken()
|
||||
// WeightUtil.connect { connect ->
|
||||
@@ -166,5 +166,12 @@ class HomeActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
@SuppressLint("GestureBackNavigation", "MissingSuperCall")
|
||||
override fun onBackPressed() {
|
||||
//super.onBackPressed()
|
||||
//当前页面不允许返回
|
||||
//dialog = toast("不允许返回操作")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,10 +54,12 @@ class InitActivity : BaseActivity() {
|
||||
BaseApp.configUrl = UrlConfig.BASE_URL
|
||||
BaseApp.canteenId = "0"
|
||||
// TODO: 以上保存deviceId用于临时使用,后续改为下面注释方式
|
||||
|
||||
// var deviceId = AppUtil.getUDID(this)
|
||||
// Log.d(TAG, "onCreate: deviceId=$deviceId")
|
||||
//// deviceId = "39a7abdd06b3c7ab"
|
||||
//// deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e"
|
||||
//// deviceId = "6ce7cd59-b875-38b2-b73d-88a570be3212"
|
||||
//
|
||||
// BaseApp.deviceId = deviceId
|
||||
//
|
||||
@@ -71,16 +73,17 @@ class InitActivity : BaseActivity() {
|
||||
// initConfig()
|
||||
// return
|
||||
// }
|
||||
|
||||
binding.ivQrCode.invisible()
|
||||
binding.btnInit.invisible()
|
||||
|
||||
initViewModel()
|
||||
WeightUtil.init()
|
||||
// WeightUtil.connect {}
|
||||
WeightUtil.getWeight()
|
||||
WeightUtil.startContinuousRead()
|
||||
HttpUtil.getAppToken()
|
||||
|
||||
HttpUtil.loopGetToken = true
|
||||
countDown()
|
||||
}
|
||||
|
||||
@@ -142,7 +145,8 @@ class InitActivity : BaseActivity() {
|
||||
// 倒计时结束执行跳转
|
||||
if (it == 1) {
|
||||
startNextPage()
|
||||
finish()
|
||||
//保留初始化页面,不关闭
|
||||
// finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +160,7 @@ class InitActivity : BaseActivity() {
|
||||
)
|
||||
)
|
||||
binding.btnInit.setOnClickListener {
|
||||
HttpUtil.loopGetToken = false
|
||||
getDeviceConfig()
|
||||
}
|
||||
}
|
||||
@@ -181,6 +186,7 @@ class InitActivity : BaseActivity() {
|
||||
toast("初始化设备失败,请稍后重试")
|
||||
return@get
|
||||
}
|
||||
HttpUtil.loopGetToken = true
|
||||
SpTool.put(SpTool.DEVICE_CONFIG_CACHE, data)
|
||||
startActivity<HomeActivity>()
|
||||
finish()
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
android:id="@+id/radioZk"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:checked="true"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="总库食堂"
|
||||
|
||||
Reference in New Issue
Block a user