refactor(frame): 优化基类,添加请求状态的支持
This commit is contained in:
@ -1,8 +1,14 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.common.ui
|
||||
|
||||
import android.util.Log
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.jaeger.library.StatusBarUtil
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameActivity
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.vm.BaseViewModel
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.ActivityStackManager
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.AndroidBugFixUtils
|
||||
import com.quyunshuo.androidbaseframemvvm.common.R
|
||||
|
||||
/**
|
||||
* Activity基类
|
||||
@ -10,7 +16,22 @@ import com.quyunshuo.androidbaseframemvvm.base.utils.AndroidBugFixUtils
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
abstract class BaseActivity<VB : ViewBinding> : BaseFrameActivity<VB>() {
|
||||
abstract class BaseActivity<VB : ViewBinding, VM : BaseViewModel> : BaseFrameActivity<VB, VM>() {
|
||||
|
||||
/**
|
||||
* 设置状态栏
|
||||
* 子类需要自定义时重写该方法即可
|
||||
* @return Unit
|
||||
*/
|
||||
override fun setStatusBar() {
|
||||
val themeColor = ContextCompat.getColor(this, R.color.common_theme)
|
||||
StatusBarUtil.setColor(this, themeColor, 0)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Log.d("ActivityLifecycle", "ActivityStack: ${ActivityStackManager.activityStack}")
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
@ -2,6 +2,7 @@ package com.quyunshuo.androidbaseframemvvm.common.ui
|
||||
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameFragment
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.vm.BaseViewModel
|
||||
|
||||
/**
|
||||
* Fragment基类
|
||||
@ -9,4 +10,4 @@ import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameFragment
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
abstract class BaseFragment<VB : ViewBinding> : BaseFrameFragment<VB>()
|
||||
abstract class BaseFragment<VB : ViewBinding, VM : BaseViewModel> : BaseFrameFragment<VB, VM>()
|
||||
@ -1,20 +0,0 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.common.ui
|
||||
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameNotMVVMActivity
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.AndroidBugFixUtils
|
||||
|
||||
/**
|
||||
* 不是 MVVM 模式的基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 9/10/20
|
||||
*/
|
||||
abstract class BaseNotMVVMActivity<VB : ViewBinding> : BaseFrameNotMVVMActivity<VB>() {
|
||||
|
||||
override fun onDestroy() {
|
||||
// 解决某些特定机型会触发的Android本身的Bug
|
||||
AndroidBugFixUtils().fixSoftInputLeaks(this)
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package com.quyunshuo.androidbaseframemvvm.common.ui
|
||||
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameNotMVVMFragment
|
||||
|
||||
/**
|
||||
* 不是 MVVM 模式的基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 9/10/20
|
||||
*/
|
||||
abstract class BaseNotMVVMFragment<VB : ViewBinding> : BaseFrameNotMVVMFragment<VB>()
|
||||
5
lib_common/src/main/res/values/colors.xml
Normal file
5
lib_common/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- 主题色 -->
|
||||
<color name="common_theme">#00BCD4</color>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user