启动页面优化
This commit is contained in:
@@ -20,10 +20,13 @@ import com.shuwei.dish.match.dialog.Loading
|
||||
import com.shuwei.dish.match.http.HttpUtil
|
||||
import com.shuwei.dish.match.http.UrlConfig
|
||||
import com.shuwei.dish.match.ui.HomeActivity.Companion.TAG
|
||||
import com.shuwei.dish.match.ui.InitActivity
|
||||
import com.shuwei.dish.match.utils.ActivityManager
|
||||
import com.shuwei.dish.match.utils.ext.gone
|
||||
import com.shuwei.dish.match.utils.ext.invisible
|
||||
import com.shuwei.dish.match.utils.ext.put
|
||||
import com.shuwei.dish.match.utils.ext.toast
|
||||
import com.shuwei.dish.match.utils.ext.visible
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
@@ -50,6 +53,9 @@ open class BaseActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
ActivityManager.addActivity(this)
|
||||
binding = ActivityBaseBinding.inflate(layoutInflater)
|
||||
if (this !is InitActivity) {
|
||||
binding.root.setBackgroundColor(ContextCompat.getColor(this, R.color.bg_color))
|
||||
}
|
||||
setContentView(binding.root)
|
||||
statusBarDarkFont(enable = false)
|
||||
launcher =
|
||||
@@ -69,6 +75,11 @@ open class BaseActivity : AppCompatActivity() {
|
||||
binding.ivBack.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
private var bgState = true
|
||||
fun useBackground(enable: Boolean) {
|
||||
bgState = enable
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
dismissLoading()
|
||||
super.onDestroy()
|
||||
@@ -103,6 +114,12 @@ open class BaseActivity : AppCompatActivity() {
|
||||
rightIconActon?.invoke(binding.ivRightIcon)
|
||||
}
|
||||
|
||||
fun setHeaderBgVisible(show: Boolean) {
|
||||
binding.ivHeaderBg.let {
|
||||
if (show) it.visible() else it.invisible()
|
||||
}
|
||||
}
|
||||
|
||||
public fun setHeaderBackground(isHomePage: Boolean = false) {
|
||||
binding.ivHeaderBg.setImageResource(
|
||||
if (isHomePage) R.drawable.bg_home_page else R.drawable.bg_other_page
|
||||
|
||||
@@ -41,38 +41,41 @@ class InitActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
statusBarDarkFont(enable = true)
|
||||
// useBackground(false)
|
||||
binding = ActivityInitBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setHeaderBackground(isHomePage = true)
|
||||
|
||||
// 获取 ANDROID_ID
|
||||
var androidId =
|
||||
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
androidId = "39a7abdd06b3c7ab"
|
||||
BaseApp.deviceId = androidId
|
||||
SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
BaseApp.configUrl = UrlConfig.BASE_URL
|
||||
BaseApp.canteenId = "0"
|
||||
// TODO: 以上保存deviceId用于临时使用,后续改为下面注释方式
|
||||
// setHeaderBackground(isHomePage = true)
|
||||
setHeaderBgVisible(false)
|
||||
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
// }
|
||||
// // 获取 ANDROID_ID
|
||||
// var androidId =
|
||||
// Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
// androidId = "39a7abdd06b3c7ab"
|
||||
// BaseApp.deviceId = androidId
|
||||
// SpTool.put(SpTool.DEVICE_ID, androidId)
|
||||
// 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
|
||||
|
||||
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()
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
<solid android:color="@color/bg_color"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:gravity="top" android:width="828dp" android:height="414dp">
|
||||
<bitmap android:src="@drawable/bg_home_page"/>
|
||||
<item
|
||||
android:width="450dp"
|
||||
android:height="430dp"
|
||||
android:gravity="top|center_horizontal"
|
||||
android:top="250dp">
|
||||
<bitmap android:src="@drawable/img_init" android:scaleType="fitCenter"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg_color">
|
||||
tools:background="@color/bg_color">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHeaderBg"
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="500dp"
|
||||
android:layout_height="500dp"
|
||||
android:layout_width="450dp"
|
||||
android:layout_height="430dp"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginTop="250dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/img_init"
|
||||
tools:ignore="ContentDescription" />
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btnInit"
|
||||
|
||||
Reference in New Issue
Block a user