Commit 5bd67337 by konghaorui

修改homeFragment sp缓存写入逻辑

parent 9a1babae
...@@ -15,7 +15,6 @@ import com.yidianling.home.constract.HomeViewConfig ...@@ -15,7 +15,6 @@ import com.yidianling.home.constract.HomeViewConfig
import com.yidianling.home.constract.IHomeContract import com.yidianling.home.constract.IHomeContract
import com.yidianling.home.model.HomeModelImpl import com.yidianling.home.model.HomeModelImpl
import com.yidianling.home.model.bean.* import com.yidianling.home.model.bean.*
import com.yidianling.home.utils.HomeLogPrinter
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Action import io.reactivex.functions.Action
...@@ -169,19 +168,6 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract ...@@ -169,19 +168,6 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
Observable.mergeArray(*mergeArrays.toTypedArray()) Observable.mergeArray(*mergeArrays.toTypedArray())
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doOnComplete {
if (homeList.size == mergeArrays.size){
ThreadUtils.doOnThread(object : ThreadUtils.ThreadTask{
override fun doOnThread() {
SharedPreferencesEditor.putString(CACHE_HOME_PAGER_DATA, Gson().toJson(homeList))
SharedPreferencesEditor.putString(
HOME_PAGER_DATA_CACHE_VERISON,
RxAppTool.getAppVersionCode(BaseApp.getApp()).toString()
)
}
})
}
}
.subscribe(Consumer {}, object : ThrowableConsumer() { .subscribe(Consumer {}, object : ThrowableConsumer() {
override fun accept(msg: String) { override fun accept(msg: String) {
mView.homeDataFail(msg) mView.homeDataFail(msg)
...@@ -205,10 +191,21 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract ...@@ -205,10 +191,21 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
mView.homeDataResponse(homeList) mView.homeDataResponse(homeList)
//更新本地缓存数据 //更新本地缓存数据
HomeLogPrinter.printLongLog( ThreadUtils.doOnThread(object : ThreadUtils.ThreadTask{
HomePresenterImpl::class.java.simpleName, override fun doOnThread() {
Gson().toJson(homeList) SharedPreferencesEditor.putString(CACHE_HOME_PAGER_DATA, Gson().toJson(homeList))
) SharedPreferencesEditor.putString(
HOME_PAGER_DATA_CACHE_VERISON,
RxAppTool.getAppVersionCode(BaseApp.getApp()).toString()
)
}
})
//长日志打印
// HomeLogPrinter.printLongLog(
// HomePresenterImpl::class.java.simpleName,
// Gson().toJson(homeList)
// )
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment