diff --git a/app/src/main/java/com/wjx/android/wanandroidmvvm/module/common/view/ArticleListFragment.kt b/app/src/main/java/com/wjx/android/wanandroidmvvm/module/common/view/ArticleListFragment.kt index a50a81e..e917c34 100644 --- a/app/src/main/java/com/wjx/android/wanandroidmvvm/module/common/view/ArticleListFragment.kt +++ b/app/src/main/java/com/wjx/android/wanandroidmvvm/module/common/view/ArticleListFragment.kt @@ -49,11 +49,11 @@ abstract class ArticleListFragment> : BaseLifeCycleFrag article?.let { mViewModel.addFootPrint(article) - CommonUtil.startWebView(activity!!, it.link, it.title) + CommonUtil.startWebView(requireActivity()!!, it.link, it.title) } } mAdapter.setOnItemChildClickListener { _, _, position -> - UserInfo.instance.collect(activity!!, position, this) + UserInfo.instance.collect(requireActivity()!!, position, this) } mAdapter.setEnableLoadMore(true) mAdapter.setOnLoadMoreListener({ onLoadMoreData() }, mRvArticle) @@ -63,7 +63,7 @@ abstract class ArticleListFragment> : BaseLifeCycleFrag private fun initRefresh() { // 设置下拉刷新的loading颜色 - mSrlRefresh.setProgressBackgroundColorSchemeColor(ColorUtil.getColor(activity!!)) + mSrlRefresh.setProgressBackgroundColorSchemeColor(ColorUtil.getColor(requireActivity()!!)) mSrlRefresh.setColorSchemeColors(Color.WHITE) mSrlRefresh.setOnRefreshListener { onRefreshData() } } @@ -140,7 +140,7 @@ abstract class ArticleListFragment> : BaseLifeCycleFrag @Subscribe fun settingEvent(event: ChangeThemeEvent) { - mSrlRefresh.setProgressBackgroundColorSchemeColor(ColorUtil.getColor(activity!!)) + mSrlRefresh.setProgressBackgroundColorSchemeColor(ColorUtil.getColor(requireActivity()!!)) mAdapter.notifyDataSetChanged() } } \ No newline at end of file diff --git a/app/src/main/java/com/wjx/android/wanandroidmvvm/module/home/repository/HomeRepository.kt b/app/src/main/java/com/wjx/android/wanandroidmvvm/module/home/repository/HomeRepository.kt index 7dea10e..f1cc9d1 100644 --- a/app/src/main/java/com/wjx/android/wanandroidmvvm/module/home/repository/HomeRepository.kt +++ b/app/src/main/java/com/wjx/android/wanandroidmvvm/module/home/repository/HomeRepository.kt @@ -65,7 +65,6 @@ class HomeRepository(loadState: MutableLiveData) : ArticleRepository(load // 使用协程 + Retrofit2.6 suspend fun loadBannerCo(): List { return apiService.loadBannerCo().dataConvert(loadState) - } suspend fun loadTopArticleCo(): List
{ diff --git a/mvvm/build.gradle b/mvvm/build.gradle index c12751f..1d4a065 100644 --- a/mvvm/build.gradle +++ b/mvvm/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'com.android.application' +apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'com.github.dcendents.android-maven' @@ -10,7 +10,6 @@ android { buildToolsVersion "29.0.2" defaultConfig { - applicationId "com.wjx.android.myapplication" minSdkVersion 26 targetSdkVersion 29 versionCode 1 diff --git a/mvvm/src/main/java/com/wjx/android/mvvm/BaseApplication.kt b/mvvm/src/main/java/com/wjx/android/mvvm/BaseApplication.kt index e46c4eb..a80a332 100644 --- a/mvvm/src/main/java/com/wjx/android/mvvm/BaseApplication.kt +++ b/mvvm/src/main/java/com/wjx/android/mvvm/BaseApplication.kt @@ -2,9 +2,8 @@ package com.wjx.android.mvvm import android.app.Application import androidx.appcompat.app.AppCompatDelegate -import com.kingja.loadsir.core.LoadSir -import com.wjx.android.wanandroidmvvm.common.utils.Constant -import com.wjx.android.wanandroidmvvm.common.utils.SPreference +import com.wjx.android.mvvm.common.utils.Constant +import com.wjx.android.mvvm.common.utils.SPreference /** * Created with Android Studio. @@ -20,11 +19,5 @@ open class BaseApplication : Application() { super.onCreate() instance = this SPreference.setContext(applicationContext) - initMode() - } - - private fun initMode() { - var isNightMode: Boolean by SPreference(Constant.NIGHT_MODE, false) - AppCompatDelegate.setDefaultNightMode(if (isNightMode) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO) } } \ No newline at end of file diff --git a/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseActivity.kt b/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseActivity.kt index 8a58efd..f5f02d9 100644 --- a/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseActivity.kt +++ b/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseActivity.kt @@ -58,20 +58,4 @@ abstract class BaseActivity, DB : ViewDataBinding> : AppCo super.onDestroy() AppManager.instance.removeActivity(this) } - - private fun initStatusColor(color: Int) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - window.statusBarColor = ContextCompat.getColor(this, - R.color.always_white_text - ) - } - if (ColorUtils.calculateLuminance(getColor(R.color.always_white_text)) >= 0.5) { - // 设置状态栏中字体的颜色为黑色 - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR - } else { - // 跟随系统 - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE - } - } - } \ No newline at end of file diff --git a/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseFragment.kt b/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseFragment.kt index 4550941..66d34ea 100644 --- a/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseFragment.kt +++ b/mvvm/src/main/java/com/wjx/android/mvvm/view/BaseFragment.kt @@ -5,16 +5,12 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.content.ContextCompat -import androidx.core.graphics.ColorUtils import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider -import com.kingja.loadsir.core.LoadService -import com.wjx.android.mvvm.R +import com.wjx.android.mvvm.common.utils.CommonUtil import com.wjx.android.mvvm.viewmodel.BaseViewModel -import com.wjx.android.wanandroidmvvm.common.utils.CommonUtil /** * Created with Android Studio. @@ -27,8 +23,6 @@ abstract class BaseFragment, DB : ViewDataBinding> : Fragm protected lateinit var mDataBinding: DB - protected lateinit var loadService: LoadService<*> - open fun initView() {} open fun initData() {} @@ -51,24 +45,5 @@ abstract class BaseFragment, DB : ViewDataBinding> : Fragm override fun onViewCreated(view: View, savedInstanceState: Bundle?) { initView() initData() - initStatusBarColor() - } - - private fun initStatusBarColor() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - requireActivity().window.statusBarColor = ContextCompat.getColor( - requireActivity(), - R.color.always_white_text - ) - } - if (ColorUtils.calculateLuminance(requireContext().getColor(R.color.always_white_text)) >= 0.5) { - // 设置状态栏中字体的颜色为黑色 - requireActivity().window.decorView.systemUiVisibility = - View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR - } else { - // 跟随系统 - requireActivity().window.decorView.systemUiVisibility = - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - } } } \ No newline at end of file