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