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