Commit 23099a89 by 徐健

首页数据缓存设置位5秒后缓存,放置数据存取错乱

parent 40cea21d
...@@ -58,25 +58,30 @@ class HomeConsultBean: HomeItemBaseBean { ...@@ -58,25 +58,30 @@ class HomeConsultBean: HomeItemBaseBean {
*/ */
//字段名称改了 //字段名称改了
var uid: Int = 0
var doctorUid: Int = 0 var doctorUid: Int = 0
var doctorId: String = "" var doctorId: String = ""
var doctorName: String? = null var name: String = ""
var doctorHead: String? = null var doctorName: String = ""
var profesBack: String? = null var head: String = ""
var doctorHead: String = ""
var profesBack: String = ""
var minBookingPrice: Int = 0
var serviceFee: Int = 0 var serviceFee: Int = 0
var zixunOrderNum: Int = 0 var zixunOrderNum: Int = 0
var feedbackRate: Float = 0f var feedbackRate: Float = 0f
var province: String? = null var province: String = ""
var city: String? = null var city: String = ""
var isOnline: Int = 0 var isOnline: Int = 0
var mUrl: String? = null var mUrl: String = ""
var hUrl: String? = null var linkUrl: String = ""
var hUrl: String = ""
var share: ShareBean? = null var share: ShareBean? = null
var isHiddenXcx: String? = null var isHiddenXcx: String = ""
var tags: String? = null var tags: String = ""
//私聊文案 //私聊文案
var chatBtnText: String? = null var chatBtnText: String = ""
class ShareBean { class ShareBean {
/** /**
...@@ -87,11 +92,11 @@ class HomeConsultBean: HomeItemBaseBean { ...@@ -87,11 +92,11 @@ class HomeConsultBean: HomeItemBaseBean {
* share_url : https://m.ydl.com/experts/1614 * share_url : https://m.ydl.com/experts/1614
*/ */
var title: String? = null var title: String = ""
var cover: String? = null var cover: String = ""
var desc: String? = null var desc: String = ""
var shareUrl: String? = null var shareUrl: String = ""
var share_url: String? = null var share_url: String = ""
} }
} }
} }
...@@ -10,24 +10,24 @@ class HomePagerDataBean() { ...@@ -10,24 +10,24 @@ class HomePagerDataBean() {
this.type = type; this.type = type;
} }
constructor(homeHeaderBean: HomeHeaderBean, constructor(headerBean: HomeHeaderBean,
homeConsultBean: HomeConsultBean, consultBean: HomeConsultBean,
homeConfideBean: HomeConfideBean, confideBean: HomeConfideBean,
homeCourseBean: HomeCourseBean, courseBean: HomeCourseBean,
testListBean: MutableList<HomeTestItemBean>?, testListBean: MutableList<HomeTestItemBean>?,
homeAskBean: HomeAskBean, askBean: HomeAskBean,
museBean: MuseModuleBean, museBean: MuseModuleBean,
homeFMBean: HomeFMBean, fmBean: HomeFMBean,
homeArticleBean: HomeArticleBean):this(){ articleBean: HomeArticleBean):this(){
this.headerBean = homeHeaderBean this.headerBean = headerBean
this.consultBean = homeConsultBean this.consultBean = consultBean
this.articleBean = homeArticleBean this.articleBean = articleBean
this.askBean = homeAskBean this.askBean = askBean
this.courseBean = homeCourseBean this.courseBean = courseBean
this.testListBean = testListBean this.testListBean = testListBean
this.museBean = museBean this.museBean = museBean
this.fmBean = homeFMBean this.fmBean = fmBean
this.confideBean = homeConfideBean this.confideBean = confideBean
} }
/** /**
* 咨询模块数据 * 咨询模块数据
......
...@@ -27,6 +27,7 @@ import io.reactivex.functions.Consumer ...@@ -27,6 +27,7 @@ import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit
/** /**
...@@ -55,17 +56,17 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac ...@@ -55,17 +56,17 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
.setHotSearch(it) .setHotSearch(it)
} }
} }
//BUTTON_BANNER_VIEW的数据与PAGER_BANNER_VIEW一致,不需要再次设置 YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW -> {
// YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW -> {
// homeBean.headerBean = dataBean.headerBean
// }
YdlHomeViewHolderConstract.CONSULT_VIEW -> {
homeBean.headerBean = dataBean.headerBean homeBean.headerBean = dataBean.headerBean
dataBean.headerBean?.keywordData?.let {
ModularServiceManager.provide(IConsultantService::class.java)
.setHotSearch(it)
}
}
YdlHomeViewHolderConstract.CONSULT_VIEW -> {
homeBean.consultBean = dataBean.consultBean homeBean.consultBean = dataBean.consultBean
} }
YdlHomeViewHolderConstract.CONFIDE_VIEW -> { YdlHomeViewHolderConstract.CONFIDE_VIEW -> {
homeBean.headerBean = dataBean.headerBean
homeBean.confideBean = dataBean.confideBean homeBean.confideBean = dataBean.confideBean
} }
YdlHomeViewHolderConstract.COURSE_VIEW -> { YdlHomeViewHolderConstract.COURSE_VIEW -> {
...@@ -244,13 +245,21 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac ...@@ -244,13 +245,21 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
}, Action { }, Action {
homeList.sortWith(compareBy { it.type }) homeList.sortWith(compareBy { it.type })
//更新本地缓存数据,这边顶部数据保存了两份,一个10001,一个10002,防止第二次进来读取的时候homeDataResponse回调中的remove(0)把10002删除 //更新本地缓存数据,这边顶部数据保存了两份,一个10001,一个10002,防止第二次进来读取的时候homeDataResponse回调中的remove(0)把10002删除
SharedPreferencesEditor.putString(CACHE_HOME_PAGER_DATA, Gson().toJson(homeList))
Observable.interval(5000, TimeUnit.SECONDS)
.compose(RxUtils.applySchedulers(mView))
.subscribe {
SharedPreferencesEditor.putString(CACHE_HOME_PAGER_DATA, Gson().toJson(homeList))
SharedPreferencesEditor.putString(IS_NEW_CACHE_HOME_PAGER_DATA, true.toString())
SharedPreferencesEditor.putString(
HOME_PAGER_DATA_CACHE_VERISON,
RxAppTool.getAppVersionCode(BaseApp.getApp()).toString()
)
}
mView.homeDataResponse(homeList) mView.homeDataResponse(homeList)
SharedPreferencesEditor.putString(IS_NEW_CACHE_HOME_PAGER_DATA, true.toString())
SharedPreferencesEditor.putString(
HOME_PAGER_DATA_CACHE_VERISON,
RxAppTool.getAppVersionCode(BaseApp.getApp()).toString()
)
HomeLogPrinter.printLongLog( HomeLogPrinter.printLongLog(
HomePresenterImpl::class.java.simpleName, HomePresenterImpl::class.java.simpleName,
Gson().toJson(homeList) Gson().toJson(homeList)
......
...@@ -49,7 +49,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent: ...@@ -49,7 +49,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
//设置头像 //设置头像
setHead(bean) setHead(bean)
//设置名称 //设置名称
tv_consult_name.text = bean.doctorName tv_consult_name.text = bean.name
//咨询师标签 //咨询师标签
tag_view.initData(StringUtils.strToList(bean.tags)) tag_view.initData(StringUtils.strToList(bean.tags))
//设置向TA倾诉人数 //设置向TA倾诉人数
...@@ -70,7 +70,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent: ...@@ -70,7 +70,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
* 设置头像 * 设置头像
*/ */
private fun setHead(bean: HomeConsultBean.ListBean) { private fun setHead(bean: HomeConsultBean.ListBean) {
YDLImageCacheManager.showImage(mContext, bean?.doctorHead, img_consult_head) YDLImageCacheManager.showImage(mContext, bean?.head, img_consult_head)
} }
/** /**
...@@ -139,7 +139,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent: ...@@ -139,7 +139,7 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
} }
private fun setPrice(bodyBean: HomeConsultBean.ListBean) { private fun setPrice(bodyBean: HomeConsultBean.ListBean) {
val confideFee = bodyBean.serviceFee val confideFee = bodyBean.minBookingPrice
tv_consult_price.text = "¥$confideFee" tv_consult_price.text = "¥$confideFee"
} }
} }
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