接口联调2
This commit is contained in:
@@ -8,7 +8,6 @@ import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.util.SparseArray
|
||||
import android.util.SparseIntArray
|
||||
import androidx.activity.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -29,8 +28,6 @@ import com.shuwei.intelligent.shelves.task.TaskManager
|
||||
import com.shuwei.intelligent.shelves.utils.UIUtils
|
||||
import com.shuwei.intelligent.shelves.utils.f2C
|
||||
import com.shuwei.intelligent.shelves.utils.hexToDec
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@@ -91,43 +88,40 @@ class HomeActivity : BaseActivity() {
|
||||
|
||||
//SerialPortManager.send(DEVICE_INFO_CMD)
|
||||
}
|
||||
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.getShelfListUiState.collect { state ->
|
||||
when (state) {
|
||||
is UiState.Loading -> showProgress()
|
||||
is UiState.Success<*> -> updateUI(state.data)
|
||||
is UiState.Error -> showError(state.msg)
|
||||
else -> {}
|
||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
launch {
|
||||
viewModel.getAccessTokenUiState.collect { state ->
|
||||
when (state) {
|
||||
is UiState.Loading -> {}
|
||||
is UiState.Success<*> -> getTokenSuccess(state.data)
|
||||
is UiState.Error -> UIUtils.toast(state.msg)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.getAccessTokenUiState.collect { state ->
|
||||
when (state) {
|
||||
is UiState.Loading -> {}
|
||||
is UiState.Success<*> -> getTokenSuccess(state.data)
|
||||
is UiState.Error -> UIUtils.toast(state.msg)
|
||||
else -> {}
|
||||
launch {
|
||||
viewModel.getShelfListUiState.collect { state ->
|
||||
when (state) {
|
||||
is UiState.Loading -> showProgress()
|
||||
is UiState.Success<*> -> updateUI(state.data)
|
||||
is UiState.Error -> showError(state.msg)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskManager.startTask()
|
||||
|
||||
App.get().androidId = "53babf69-0d2f-3875-a649-f2e12f80ad4c1"
|
||||
// Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
Log.d(TAG, "onCreate: androidId=${App.get().androidId}")
|
||||
val androidId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
Log.d(TAG, "onCreate: androidId=${androidId}")
|
||||
App.getInstance().deviceId = "53babf69-0d2f-3875-a649-f2e12f80ad4c1"
|
||||
|
||||
val swDpValue = resources?.configuration?.smallestScreenWidthDp
|
||||
Log.d(TAG, "onCreate: swDpValue=$swDpValue")
|
||||
|
||||
viewModel.getShelfList(deviceId = App.get().androidId)
|
||||
|
||||
|
||||
|
||||
|
||||
viewModel.getAccessToken(App.get().androidId)
|
||||
viewModel.getAccessToken(App.getInstance().deviceId)
|
||||
|
||||
// repeat(100) {
|
||||
// lifecycleScope.launch {
|
||||
@@ -141,7 +135,9 @@ class HomeActivity : BaseActivity() {
|
||||
private fun getTokenSuccess(data: RespData<*>) {
|
||||
Log.d(TAG, "getTokenSuccess: $data")
|
||||
data.result?.let {
|
||||
//App.get().accessToken = it.toString()
|
||||
App.getInstance().accessToken = it.toString()
|
||||
//UIUtils.toast(it.toString())
|
||||
viewModel.getShelfList(deviceId = App.getInstance().deviceId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +152,7 @@ class HomeActivity : BaseActivity() {
|
||||
UIUtils.toast("数据错误")
|
||||
return
|
||||
}
|
||||
App.getInstance().canteenId = data.result.canteenId
|
||||
val tempList = data.result.containerGoodsList
|
||||
if (tempList.isNullOrEmpty()) {
|
||||
UIUtils.toast("数据为空")
|
||||
|
||||
Reference in New Issue
Block a user