From 89d5407524d4a422aff5cbc7093537e712778451 Mon Sep 17 00:00:00 2001 From: beiger <1441512921@qq.com> Date: Sun, 16 Dec 2018 19:40:00 +0800 Subject: [PATCH] fix bug --- app/src/main/java/com/bing/mvvmbase/MainActivity.kt | 2 +- .../base/recycleview/BaseRecycleViewActivity.kt | 2 +- .../base/recycleview/BaseRecycleViewAdapter.kt | 8 +++----- .../base/recycleview/BaseRecycleViewFragment.kt | 12 ++++++------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/bing/mvvmbase/MainActivity.kt b/app/src/main/java/com/bing/mvvmbase/MainActivity.kt index 9873946..2fd05c0 100644 --- a/app/src/main/java/com/bing/mvvmbase/MainActivity.kt +++ b/app/src/main/java/com/bing/mvvmbase/MainActivity.kt @@ -14,7 +14,7 @@ class MainActivity : BaseActivity() { } override fun bindAndObserve() { - + mBinding.isInitialized() } override fun onClick(v: View) { diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.kt b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.kt index 2acf1ce..c37bd7c 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.kt +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewActivity.kt @@ -89,7 +89,7 @@ abstract class BaseRecycleViewActivity mAdapter.data = data }) + data.observe(this, Observer { data -> mAdapter.mData = data }) networkState.observe(this, Observer { status -> if (status == null) { return@Observer diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewAdapter.kt b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewAdapter.kt index ac68b72..726bbd5 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewAdapter.kt +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewAdapter.kt @@ -12,12 +12,10 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView abstract class BaseRecycleViewAdapter> : RecyclerView.Adapter() { - protected var mData: List? = ArrayList() - protected var mListener: OnClickListener? = null + open var mData: List? = ArrayList() + open var mListener: OnClickListener? = null - var data: List? - get() = mData - set(data) { + fun setData(data: List?) { if (data == null) { return } diff --git a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewFragment.kt b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewFragment.kt index 8d4498e..9d6ae21 100644 --- a/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewFragment.kt +++ b/mvvmbase/src/main/java/com/bing/mvvmbase/base/recycleview/BaseRecycleViewFragment.kt @@ -74,7 +74,7 @@ abstract class BaseRecycleViewFragment if (status == null) { return@Observer @@ -129,7 +129,7 @@ abstract class BaseRecycleViewFragment mAdapter.data = list }) + data.observe(this, Observer { list -> mAdapter.mData = list }) refreshState.observe(this, Observer { status -> if (status != Status.LOADING) { mRefreshLayout.finishRefresh(status == Status.SUCCESS)