Commit b45d4f69 authored by shiyl's avatar shiyl

锁定应用为竖屏,并修改生活名称修改的UI问题

parent 27489ca6
package com.yidian.common.base
import android.annotation.SuppressLint
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.View
import androidx.viewbinding.ViewBinding
......@@ -10,75 +12,79 @@ import com.yidian.nightmode.preference.NightModeConfig
import com.yidian.xpage.XPageViewProtocol
abstract class BaseActivity<VB :ViewBinding> : NightAppCompatActivity(), XPageViewProtocol {
protected lateinit var viewBind:VB
abstract class BaseActivity<VB : ViewBinding> : NightAppCompatActivity(), XPageViewProtocol {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBind = createViewBinding()
extraViewBinding()
setContentView(viewBind.root)
init(savedInstanceState)
}
protected lateinit var viewBind: VB
/**
* 如果有多个viewBinding需要初始化时
*/
open fun extraViewBinding() {
@SuppressLint("SourceLockedOrientationActivity")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBind = createViewBinding()
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
extraViewBinding()
setContentView(viewBind.root)
init(savedInstanceState)
}
}
/**
* 如果有多个viewBinding需要初始化时
*/
open fun extraViewBinding() {
override fun updateCover(isNight: Boolean) {}
}
override fun getCurrentTheme(isNight: Boolean): Int {
return if (isNight) R.style.subway_theme_night else R.style.subway_theme_day
}
override fun updateCover(isNight: Boolean) {}
override fun setContentView(view:View){
SystemBarUtils.setStatusBarTransparent(this.window)
if (allowChangeStatusBarTextColor() ) {
setStatusBarTextColor(NightModeConfig.getInstance().nightMode)
}
super.setContentView(view)
override fun getCurrentTheme(isNight: Boolean): Int {
return if (isNight) R.style.subway_theme_night else R.style.subway_theme_day
}
override fun setContentView(view: View) {
SystemBarUtils.setStatusBarTransparent(this.window)
if (allowChangeStatusBarTextColor()) {
setStatusBarTextColor(NightModeConfig.getInstance().nightMode)
}
super.setContentView(view)
}
private fun allowChangeStatusBarTextColor(): Boolean {
return SystemBarUtils.supportTranslucentStatusBar() && SystemBarUtils.supportChangeStatusBarTextColor()
}
abstract fun createViewBinding(): VB
private fun allowChangeStatusBarTextColor(): Boolean {
return SystemBarUtils.supportTranslucentStatusBar() && SystemBarUtils.supportChangeStatusBarTextColor()
}
override fun onNightModeChanged(isNight: Boolean) {
super.onNightModeChanged(isNight)
if (allowChangeStatusBarTextColor()) {
setStatusBarTextColor(isNight)
}
}
abstract fun createViewBinding(): VB
open fun setStatusBarTextColor(isNight: Boolean) {
if (isNight) {
if (this.useWhiteStatusBarTextColorInNightMode()) {
SystemBarUtils.setStatusBarTextColorWhite(this)
} else {
SystemBarUtils.setStatusBarTextColorBlack(this)
}
} else if (this.useBlackStatusBarTextColorInDayMode()) {
SystemBarUtils.setStatusBarTextColorBlack(this)
} else {
SystemBarUtils.setStatusBarTextColorWhite(this)
}
override fun onNightModeChanged(isNight: Boolean) {
super.onNightModeChanged(isNight)
if (allowChangeStatusBarTextColor()) {
setStatusBarTextColor(isNight)
}
}
open fun setStatusBarTextColor(isNight: Boolean) {
if (isNight) {
if (this.useWhiteStatusBarTextColorInNightMode()) {
SystemBarUtils.setStatusBarTextColorWhite(this)
} else {
SystemBarUtils.setStatusBarTextColorBlack(this)
}
} else if (this.useBlackStatusBarTextColorInDayMode()) {
SystemBarUtils.setStatusBarTextColorBlack(this)
} else {
SystemBarUtils.setStatusBarTextColorWhite(this)
}
}
private fun useBlackStatusBarTextColorInDayMode(): Boolean {
private fun useBlackStatusBarTextColorInDayMode(): Boolean {
return true
}
return true
}
private fun useWhiteStatusBarTextColorInNightMode(): Boolean {
private fun useWhiteStatusBarTextColorInNightMode(): Boolean {
return true
}
return true
}
protected open fun init(savedInstanceState: Bundle?) {}
protected open fun init(savedInstanceState: Bundle?) {}
}
......@@ -100,9 +100,9 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
// 生活号名称修改成功 发送事件通知商户基本信息页面和商户管理中心页面
XEventManager.post(XBaseEvent(XEventConfig.LIFE_ACCOUNT_NAME_MODIFY, viewBind.evLifeAccountName.getEditContent()))
XPageManager.pop(null)
} else {
// 生活号名称修改失败 提示
viewBind.evLifeAccountName.showErrorTips(resources.getString(R.string.life_account_name_already_exist))
// } else {
// // 生活号名称修改失败 提示
// viewBind.evLifeAccountName.showErrorTips(resources.getString(R.string.life_account_name_already_exist))
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment