初始化功能调试,启动页面优化
This commit is contained in:
@@ -88,6 +88,7 @@ class HomeActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityHomeBinding.inflate(layoutInflater)
|
||||
EventBus.getDefault().register(this)
|
||||
setBackground()
|
||||
setContentView(binding.root)
|
||||
|
||||
updateLeftStatus("1-1冷藏柜 -°C / -%")
|
||||
|
||||
@@ -50,31 +50,32 @@ class InitActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityInitBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
hideStatusBar()
|
||||
// // 获取 ANDROID_ID
|
||||
// val androidId =
|
||||
// Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
// App.deviceId = androidId
|
||||
// SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
// App.configUrl = UrlConfig.BASE_URL
|
||||
// App.canteenId = "0"
|
||||
|
||||
// 获取 ANDROID_ID
|
||||
val androidId =
|
||||
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
App.deviceId = androidId
|
||||
SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
App.configUrl = UrlConfig.BASE_URL
|
||||
App.canteenId = "0"
|
||||
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"
|
||||
App.deviceId = deviceId
|
||||
|
||||
// var deviceId = AppUtil.getUDID(this)
|
||||
// Log.d(TAG, "onCreate: deviceId=$deviceId")
|
||||
//// deviceId = "39a7abdd06b3c7ab"
|
||||
//// deviceId = "3ea47dc0-3cf0-3c2f-909c-265a9a65572e"
|
||||
// App.deviceId = deviceId
|
||||
//
|
||||
// SpTool.put(SpTool.DEVICE_ID, deviceId)
|
||||
// val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE)
|
||||
// val checkResult = checkConfigData(deviceConfigCache)
|
||||
// if (checkResult.not()) {
|
||||
// binding.ivQrCode.visible()
|
||||
// binding.btnInit.visible()
|
||||
// //进行初始化操作
|
||||
// initConfig()
|
||||
// return
|
||||
// }
|
||||
SpTool.put(SpTool.DEVICE_ID, deviceId)
|
||||
val deviceConfigCache = SpTool.getString(SpTool.DEVICE_CONFIG_CACHE)
|
||||
val checkResult = checkConfigData(deviceConfigCache)
|
||||
if (checkResult.not()) {
|
||||
binding.ivQrCode.visible()
|
||||
binding.btnInit.visible()
|
||||
//进行初始化操作
|
||||
initConfig()
|
||||
return
|
||||
}
|
||||
binding.ivQrCode.invisible()
|
||||
binding.btnInit.invisible()
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ class ShelfActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityShelfBinding.inflate(layoutInflater)
|
||||
setBackground()
|
||||
setContentView(binding.root)
|
||||
EventBus.getDefault().register(this)
|
||||
// tvFoodWeight =binding.tvFoodWeight
|
||||
|
||||
@@ -46,14 +46,14 @@ open class BaseActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.setDecorFitsSystemWindows(false)
|
||||
window.insetsController?.apply {
|
||||
hide(WindowInsets.Type.statusBars()) // 隐藏状态栏
|
||||
systemBarsBehavior =
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示
|
||||
}
|
||||
}
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
// window.setDecorFitsSystemWindows(false)
|
||||
// window.insetsController?.apply {
|
||||
// hide(WindowInsets.Type.statusBars()) // 隐藏状态栏
|
||||
// systemBarsBehavior =
|
||||
// WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,10 @@ open class BaseActivity : AppCompatActivity() {
|
||||
binding.tvRightStatus.setTextColor(color)
|
||||
}
|
||||
|
||||
fun setBackground() {
|
||||
binding.root.setBackgroundColor(ContextCompat.getColor(this,R.color.bg_page))
|
||||
}
|
||||
|
||||
override fun setContentView(view: View?) {
|
||||
if (view == binding.root) {
|
||||
super.setContentView(view)
|
||||
|
||||
@@ -57,16 +57,16 @@ class NetViewModel : ViewModel() {
|
||||
|
||||
fun getDeviceConfig(deviceId: String, deviceToken: String) {
|
||||
viewModelScope.launch {
|
||||
_getDeviceTokenUiState.value = UiState.Loading
|
||||
_getDeviceConfigUiState.value = UiState.Loading
|
||||
runCatching {
|
||||
val response = apiService.getDeviceInfo(equipmentCode = deviceId, token = deviceToken)
|
||||
if (response.success) {
|
||||
_getDeviceTokenUiState.value = UiState.Success(response)
|
||||
_getDeviceConfigUiState.value = UiState.Success(response)
|
||||
} else {
|
||||
_getDeviceTokenUiState.value = UiState.Error(response.message ?: "请求失败")
|
||||
_getDeviceConfigUiState.value = UiState.Error(response.message ?: "请求失败")
|
||||
}
|
||||
}.onFailure {
|
||||
_getDeviceTokenUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
_getDeviceConfigUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- android:width="800dp"-->
|
||||
<!-- android:height="1280dp"-->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/bg_page" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="450dp"
|
||||
android:height="430dp"
|
||||
android:gravity="top|center_horizontal"
|
||||
android:top="150dp">
|
||||
<bitmap android:src="@drawable/img_init" android:scaleType="fitCenter"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- android:width="800dp"-->
|
||||
<!-- android:height="1280dp"-->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/bg_page" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="225dp"
|
||||
android:height="215dp"
|
||||
android:gravity="top|center_horizontal"
|
||||
android:top="75dp">
|
||||
<bitmap android:src="@drawable/img_init" android:scaleType="fitCenter"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -5,7 +5,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/bg_page">
|
||||
tools:background="@color/bg_page">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/flStatusBar"
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="450dp"
|
||||
android:layout_height="450dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="150dp"
|
||||
android:src="@drawable/img_init"
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btnInit"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="100dp"
|
||||
android:background="@drawable/bg_init_button"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:text="设备初始化"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivQrCode"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:layout_marginBottom="50dp"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@mipmap/ic_logo512" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -6,7 +6,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="false"
|
||||
android:background="@color/bg_page">
|
||||
tools:background="@color/bg_page">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/flStatusBar"
|
||||
|
||||
@@ -7,27 +7,26 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="450dp"
|
||||
android:layout_height="450dp"
|
||||
android:layout_width="225dp"
|
||||
android:layout_height="215dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginTop="150dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:layout_marginTop="75dp"
|
||||
android:src="@drawable/img_init"
|
||||
tools:ignore="ContentDescription" />
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btnInit"
|
||||
android:layout_width="300dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="@drawable/bg_init_button"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:text="设备初始化"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible"
|
||||
tools:ignore="HardcodedText" />
|
||||
@@ -39,10 +38,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivQrCode"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@mipmap/ic_logo512" />
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<!-- <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>-->
|
||||
<item name="android:statusBarColor">@color/white</item>
|
||||
<item name="android:windowBackground">@drawable/bg_splash</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -10,7 +10,9 @@
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<item name="android:statusBarColor">@color/bg_page</item>
|
||||
<!-- <item name="android:statusBarColor">@color/white</item>-->
|
||||
<item name="android:windowBackground">@drawable/bg_splash</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="LoadingDialog" parent="Theme.AppCompat.Dialog">
|
||||
|
||||
Reference in New Issue
Block a user