feat: 添加DI框架Hilt,重构基类部分,添加module_home模块示例用法
This commit is contained in:
@@ -13,7 +13,7 @@ import kotlin.system.measureTimeMillis
|
||||
* @author Qu Yunshuo
|
||||
* @since 4/24/21 5:30 PM
|
||||
*/
|
||||
class BaseApplication : MultiDexApplication() {
|
||||
open class BaseApplication : MultiDexApplication() {
|
||||
|
||||
private val mCoroutineScope by lazy(mode = LazyThreadSafetyMode.NONE) { MainScope() }
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/8/27
|
||||
* @Class: BaseRepository
|
||||
* @Remark: 仓库层 Repository 基类
|
||||
* 仓库层 Repository 基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
open class BaseRepository {
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.quyunshuo.androidbaseframemvvm.base.mvvm.v
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.BindingReflex
|
||||
@@ -10,22 +9,17 @@ import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusRegister
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusUtils
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/8/27
|
||||
* @Class: BaseFrameActivity
|
||||
* @Remark: Activity基类 与项目无关
|
||||
* Activity基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
abstract class BaseFrameActivity<VB : ViewBinding, VM : ViewModel> :
|
||||
AppCompatActivity(), FrameView<VB> {
|
||||
abstract class BaseFrameActivity<VB : ViewBinding> : AppCompatActivity(), FrameView<VB> {
|
||||
|
||||
protected val mBinding: VB by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
BindingReflex.reflexViewBinding(javaClass, layoutInflater)
|
||||
}
|
||||
|
||||
protected val mViewModel: VM by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
BindingReflex.reflexViewModel(javaClass, this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(mBinding.root)
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.BindingReflex
|
||||
@@ -13,21 +12,17 @@ import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusRegister
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusUtils
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/8/27
|
||||
* @Class: BaseFrameFragment
|
||||
* @Remark: Fragment基类 与项目无关
|
||||
* Fragment基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
abstract class BaseFrameFragment<VB : ViewBinding, VM : ViewModel> : Fragment(), FrameView<VB> {
|
||||
abstract class BaseFrameFragment<VB : ViewBinding> : Fragment(), FrameView<VB> {
|
||||
|
||||
protected val mBinding: VB by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
BindingReflex.reflexViewBinding(javaClass, layoutInflater)
|
||||
}
|
||||
|
||||
protected val mViewModel: VM by lazy(mode = LazyThreadSafetyMode.NONE) {
|
||||
BindingReflex.reflexViewModel(javaClass, this)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
||||
@@ -9,10 +9,10 @@ import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusRegister
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusUtils
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/9/10
|
||||
* @Class: BaseFrameNotMVVMActivity
|
||||
* @Remark: 不使用 MVVM 的 Activity 基类
|
||||
* 不使用 MVVM 的 Activity 基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since /9/10/20
|
||||
*/
|
||||
abstract class BaseFrameNotMVVMActivity<VB : ViewBinding> : AppCompatActivity(),
|
||||
FrameNotMVVMView<VB> {
|
||||
|
||||
@@ -12,10 +12,10 @@ import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusRegister
|
||||
import com.quyunshuo.androidbaseframemvvm.base.utils.EventBusUtils
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/9/10
|
||||
* @Class: BaseFrameNotMVVMFragment
|
||||
* @Remark: 不使用 MVVM 的 Fragment 基类
|
||||
* 不使用 MVVM 的 Fragment 基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 9/10/20
|
||||
*/
|
||||
abstract class BaseFrameNotMVVMFragment<VB : ViewBinding> : Fragment(), FrameNotMVVMView<VB> {
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.quyunshuo.androidbaseframemvvm.base.mvvm.v
|
||||
import androidx.viewbinding.ViewBinding
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/10/13
|
||||
* @Class: FrameNotMVVMView
|
||||
* @Remark: View层基类抽象
|
||||
* View层基类抽象
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 10/13/20
|
||||
*/
|
||||
interface FrameNotMVVMView<VB : ViewBinding> {
|
||||
/**
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.quyunshuo.androidbaseframemvvm.base.mvvm.v
|
||||
import androidx.viewbinding.ViewBinding
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/10/13
|
||||
* @Class: FrameView
|
||||
* @Remark: View层基类抽象
|
||||
* View层基类抽象
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 10/13/20
|
||||
*/
|
||||
interface FrameView<VB : ViewBinding> {
|
||||
/**
|
||||
|
||||
@@ -2,23 +2,18 @@ package com.quyunshuo.androidbaseframemvvm.base.mvvm.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
|
||||
|
||||
/**
|
||||
* @Author: QuYunShuo
|
||||
* @Time: 2020/8/27
|
||||
* @Class: BaseViewModel
|
||||
* @Remark: ViewModel 基类
|
||||
* ViewModel 基类
|
||||
*
|
||||
* @author Qu Yunshuo
|
||||
* @since 8/27/20
|
||||
*/
|
||||
abstract class BaseViewModel<R : BaseRepository> : ViewModel() {
|
||||
abstract class BaseViewModel : ViewModel() {
|
||||
|
||||
// Loading 状态
|
||||
val isLoading = MutableLiveData(false)
|
||||
|
||||
// 请求异常
|
||||
val requestError = MutableLiveData<Throwable?>()
|
||||
|
||||
protected val mRepository: R by lazy { initRepository() }
|
||||
|
||||
protected abstract fun initRepository(): R
|
||||
}
|
||||
Reference in New Issue
Block a user