Commit 23099a89 by 徐健

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

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