Modify: 基类调整
This commit is contained in:
@ -26,6 +26,7 @@ abstract class BaseFrameActivity<VB : ViewBinding, VM : ViewModel>(private val v
|
||||
|
||||
protected abstract fun initViewBinding(): VB
|
||||
protected abstract fun initView()
|
||||
protected abstract fun initViewObserve()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -35,6 +36,7 @@ abstract class BaseFrameActivity<VB : ViewBinding, VM : ViewModel>(private val v
|
||||
// 注册EventBus
|
||||
if (javaClass.isAnnotationPresent(EventBusRegister::class.java)) EventBusUtils.register(this)
|
||||
initView()
|
||||
initViewObserve()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@ -28,8 +28,8 @@ abstract class BaseFrameFragment<VB : ViewBinding, VM : ViewModel>(private val v
|
||||
protected val mBinding: VB by lazy(mode = LazyThreadSafetyMode.NONE) { initViewBinding() }
|
||||
|
||||
protected abstract fun initViewBinding(): VB
|
||||
|
||||
protected abstract fun initView()
|
||||
protected abstract fun initViewObserve()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@ -46,6 +46,7 @@ abstract class BaseFrameFragment<VB : ViewBinding, VM : ViewModel>(private val v
|
||||
// 注册EventBus
|
||||
if (javaClass.isAnnotationPresent(EventBusRegister::class.java)) EventBusUtils.register(this)
|
||||
initView()
|
||||
initViewObserve()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.quyunshuo.base.mvvm.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.quyunshuo.base.mvvm.m.BaseRepository
|
||||
|
||||
@ -11,6 +12,9 @@ import com.quyunshuo.base.mvvm.m.BaseRepository
|
||||
*/
|
||||
abstract class BaseViewModel<R : BaseRepository> : ViewModel() {
|
||||
|
||||
// Loading 状态
|
||||
val isLoading = MutableLiveData(false)
|
||||
|
||||
protected val mRepository: R by lazy { initRepository() }
|
||||
|
||||
protected abstract fun initRepository(): R
|
||||
|
||||
@ -17,8 +17,6 @@ import java.util.concurrent.TimeUnit
|
||||
*/
|
||||
object NetServiceCreator {
|
||||
|
||||
private const val BASE_URL = ""
|
||||
|
||||
private const val CONNECT_TIME_OUT = 15L
|
||||
|
||||
private const val READ_TIME_OUT = 20L
|
||||
@ -43,7 +41,7 @@ object NetServiceCreator {
|
||||
|
||||
private val retrofit by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.baseUrl("")
|
||||
.addConverterFactory(GsonConverterFactory.create()) // Gson转换器
|
||||
.client(okHttpClient)
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user