Commit 0667eb51 by 徐健

首页组件化基本完成(剩余部分todo)

parent e24853f5
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -85,7 +85,7 @@ class IHomeBaseContract {
/**
* 获取首页本地缓存
*/
fun localHomeData(context: Context)
fun localHomeData(context: Context, fileName: String)
/**
* 刷新首页数据请求
......
......@@ -72,7 +72,7 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
/**
* 加载本地缓存
*/
override fun localHomeData(context: Context) {
override fun localHomeData(context: Context, fileName: String) {
YDLAsyncUtils.asyncAsResult(object : YDLAsyncUtils.AsyncObjecyerResult {
override fun doAsyncAction(): Any {
......@@ -96,7 +96,7 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
if (cacheHomeData.isEmpty()) {
//第一次安装使用本地临时数据
cacheHomeData =
String(HomeFileUtils.getAssertsFile(context, "home_data.json")!!)
String(HomeFileUtils.getAssertsFile(context, fileName)!!)
}
return cacheHomeData
......
......@@ -101,10 +101,6 @@ class YdlHomeAdapter(private val mContext: Context,
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder {
when (viewType) {
//顶部ViewPager与分类模块
// YdlHomeViewHolderConstract.PAGER_BANNER_VIEW -> {
// return HomePagerBannerViewHolder(HomePagerBannerView(mContext, homeEvent))
// }
//顶部预约专家,即时倾诉,心理测试按钮模块
YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW -> {
return HomeButtonBannerViewHolder(HomeButtonBannerView(mContext, homeEvent))
......@@ -121,10 +117,6 @@ class YdlHomeAdapter(private val mContext: Context,
YdlHomeViewHolderConstract.ASSUAGE_GRIEF_VIEW -> {
return HomeAssuageGriefViewHolder(HomeAssuageGriefView(mContext, homeEvent))
}
//心灵*电台模块
YdlHomeViewHolderConstract.INTELLIGENT_VIEW -> {
return HomeIntelligentViewHolder(HomeIntelligentView(mContext, homeEvent))
}
//文章*阅读模块
YdlHomeViewHolderConstract.ARTICLE_VIEW -> {
return HomeArticleViewHolder(HomeArticleView(mContext, homeEvent))
......@@ -147,10 +139,6 @@ class YdlHomeAdapter(private val mContext: Context,
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
// //顶部ViewPager与分类模块
// is HomePagerBannerViewHolder -> {
// holder.pagerBannerView.initData(list[position].headerBean)
// }
//顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块
is HomeButtonBannerViewHolder -> {
holder.buttonBannerView.initData(list[position].headerBean?.homeSaleData,list[position].headerBean?.askCategoryData)
......@@ -169,18 +157,14 @@ class YdlHomeAdapter(private val mContext: Context,
is HomeAssuageGriefViewHolder -> {
holder.assuageGriefViewView.initData(position, list[position].askBean?.data)
}
//心灵*电台模块
is HomeIntelligentViewHolder -> {
holder.intelligentViewView.initData(list[position].fmBean?.list)
}
//文章*阅读模块
is HomeArticleViewHolder -> {
holder.articleViewView.initData(list[position].articleBean?.list)
}
//咨询模块
is HomeConsultViewHolder -> {
holder.consultView.setTitle(list[position].headerBean!!.consultCategoryData, consultSelectPosition)
holder.consultView.setConsultInfoView(list[position].consultBean?.list,list[position].headerBean!!.consultCategoryData?.get(consultSelectPosition))
holder.consultView.setTitle(list[position].headerBean?.consultCategoryData, consultSelectPosition)
holder.consultView.setConsultInfoView(list[position].consultBean?.list,list[position].headerBean?.consultCategoryData?.get(consultSelectPosition))
consultPosition = position
}
//测试模块
......@@ -193,12 +177,6 @@ class YdlHomeAdapter(private val mContext: Context,
override fun getItemCount(): Int {
return list.size
}
/**
* 顶部ViewPager与分类模块 ViewHolder
*/
// inner class HomePagerBannerViewHolder(val pagerBannerView: HomePagerBannerView) : RecyclerView.ViewHolder(pagerBannerView)
/**
* 顶部预约专家,即时倾诉,心理测试按钮模块 ViewHolder
*/
......@@ -228,12 +206,6 @@ class YdlHomeAdapter(private val mContext: Context,
* 解忧*问答模块 ViewHolder
*/
inner class HomeAssuageGriefViewHolder(val assuageGriefViewView: HomeAssuageGriefView) : RecyclerView.ViewHolder(assuageGriefViewView)
/**
* 心灵*电台模块 ViewHolder
*/
inner class HomeIntelligentViewHolder(val intelligentViewView: HomeIntelligentView) : RecyclerView.ViewHolder(intelligentViewView)
/**
* 文章*阅读模块 ViewHolder
*/
......
......@@ -22,22 +22,21 @@ class YdlHomeViewHolderConstract {
*/
val CONSULT_VIEW = 10003
/**
* 课程*成长模块
* 倾诉*排解模块
*/
val COURSE_VIEW = 10004
val CONFIDE_VIEW = 10004
/**
* 倾诉*排解模块
* 课程*成长模块
*/
val CONFIDE_VIEW = 10005
val COURSE_VIEW = 10005
/**
* 解忧*问答模块
* 测试模块
*/
val ASSUAGE_GRIEF_VIEW = 10006
val TEST_VIEW = 10006
/**
* 心灵*电台模块
* 解忧*问答模块
*/
val INTELLIGENT_VIEW = 10007
val ASSUAGE_GRIEF_VIEW = 10007
/**
* 文章*阅读模块
*/
......@@ -46,10 +45,5 @@ class YdlHomeViewHolderConstract {
* 底部提示语模块
*/
val FOOTER_VIEW = 10009
/**
* 测试模块
*/
val TEST_VIEW = 10010
}
}
\ No newline at end of file
......@@ -52,24 +52,6 @@ class HomeImpl(context: Context, homeView: IHomeContract.View) : HomeBaseImpl(co
private var lastVoiceView: ImageView? = null
private var floatViewClickListener: PlayerFloatView.FloatViewPlayListener? = null
override fun rightPlayClick(rightPlayView: ImageView) {
// if (MyPlayer.getInstance().isPlaying!!) {
// //FM播放页
// val bundle = Bundle()
// bundle.putInt("id", MyPlayer.getInstance().fmId)
//
// ARouter.getInstance()
// .build("/fm/detail")
// .withBundle("bundle", bundle)
// .navigation()
// } else if (CoursePlayer.isPlaying()) {
// //课程播放页
// CoursePlayer.startCoursePlayActivity(mContext, 2)
// } else {
// rightPlayView.visibility = View.GONE
// }
}
override fun clickEnsure(list: List<CouponBean>): CouponDialog.OnClickEnsureListener {
return object : CouponDialog.OnClickEnsureListener {
override fun clickEnsure(status: Int) {
......
......@@ -14,10 +14,6 @@ import com.yidianling.home.ui.view.CouponDialog
* @date 2019/02/13
*/
interface IHomeEvent {
/**
* 搜索框播放时间
*/
fun rightPlayClick(home_right_play: ImageView)
/**
* 点击优惠券确定事件
......
......@@ -55,10 +55,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 -> {
homeBean.headerBean = dataBean.headerBean
homeBean.consultBean = dataBean.consultBean
}
YdlHomeViewHolderConstract.CONFIDE_VIEW -> {
homeBean.headerBean = dataBean.headerBean
homeBean.confideBean = dataBean.confideBean
}
YdlHomeViewHolderConstract.COURSE_VIEW -> {
......@@ -71,9 +78,6 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
mHomeAskBean = dataBean.askBean
homeBean.askBean = dataBean.askBean
}
YdlHomeViewHolderConstract.INTELLIGENT_VIEW -> {
homeBean.fmBean = dataBean.fmBean
}
YdlHomeViewHolderConstract.ARTICLE_VIEW -> {
homeBean.articleBean = dataBean.articleBean
}
......@@ -113,13 +117,19 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
item.headerBean =
if (dataBean.isRealEmpty || dataBean !is HomeHeaderBean) homeTempData.headerBean else dataBean
}
YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW -> {
item.headerBean =
if (dataBean.isRealEmpty || dataBean !is HomeHeaderBean) homeTempData.headerBean else dataBean
}
YdlHomeViewHolderConstract.CONSULT_VIEW -> {
item.consultBean =
if (dataBean.isRealEmpty || dataBean !is HomeConsultBean) homeTempData.consultBean else dataBean
item.headerBean = homeTempData.headerBean
}
YdlHomeViewHolderConstract.CONFIDE_VIEW -> {
item.confideBean =
if (dataBean.isRealEmpty || dataBean !is HomeConfideBean) homeTempData.confideBean else dataBean
item.headerBean = homeTempData.headerBean
}
YdlHomeViewHolderConstract.COURSE_VIEW -> {
item.courseBean =
......@@ -134,10 +144,6 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
if (dataBean.isRealEmpty || dataBean !is HomeAskBean) homeTempData.askBean else dataBean
mHomeAskBean = item.askBean
}
YdlHomeViewHolderConstract.INTELLIGENT_VIEW -> {
item.fmBean =
if (dataBean.isRealEmpty || dataBean !is HomeFMBean) homeTempData.fmBean else dataBean
}
YdlHomeViewHolderConstract.ARTICLE_VIEW -> {
item.articleBean =
if (dataBean.isRealEmpty || dataBean !is HomeArticleBean) homeTempData.articleBean else dataBean
......@@ -163,6 +169,12 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
YdlHomeViewHolderConstract.PAGER_BANNER_VIEW
)
)
homeList.add(
getHomeItemFromTempData(
it,
YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW
)
)
mView.homeHeadResponse(it)
//获取咨询分类后,再次请求咨询模块数据,防止出现默认分类为空,数据不对
if (it.consultCategoryData != null && it.consultCategoryData!!.isNotEmpty()) {
......@@ -171,7 +183,7 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
getConsultData("${it.consultCategoryData!![0].id}", 0)
}
}
homeList.add(HomePagerDataBean(YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW))
// homeList.add(HomePagerDataBean(YdlHomeViewHolderConstract.BUTTON_BANNER_VIEW))
//保存热门搜索列表
it.keywordData?.let {
ModularServiceManager.provide(IConsultantService::class.java).setHotSearch(it)
......@@ -210,15 +222,6 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
)
)
},
mModel.fmRequest().map {
//首页电台数据
homeList.add(
getHomeItemFromTempData(
it,
YdlHomeViewHolderConstract.INTELLIGENT_VIEW
)
)
},
mModel.articleRequest().map {
//首页文章数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.ARTICLE_VIEW))
......@@ -232,9 +235,9 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
}
}, Action {
homeList.sortWith(compareBy { it.type })
mView.homeDataResponse(homeList)
//更新本地缓存数据
//更新本地缓存数据,这边顶部数据保存了两份,一个10001,一个10002,防止第二次进来读取的时候homeDataResponse回调中的remove(0)把10002删除
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,
......
......@@ -84,7 +84,7 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
}
private fun initAdapter() {
mPresenter?.localHomeData(this.context)
mPresenter?.localHomeData(this.context, "home_data_xlzx.json")
adapter = YdlHomeAdapter(context, homeEvent!!, ArrayList())
val layoutManager = LinearLayoutManager(context)
home_module_fragment_recycler.layoutManager = layoutManager
......@@ -99,7 +99,7 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
home_swipe_refresh_layout.setColorSchemeColors(ContextCompat.getColor(context, R.color.platform_main_theme_blue))
home_swipe_refresh_layout.setProgressViewOffset(false, 0, 200)
home_swipe_refresh_layout.isEnabled = false
etSearch.setOnClickListener { homeEvent?.searchTvClick() }
etSearch.setOnClickListener { homeEvent?.searchTvClick("") }
val inputLayoutParams = ll_search.layoutParams as CoordinatorLayout.LayoutParams
val inputOriginMargin = inputLayoutParams.leftMargin
......
......@@ -12,6 +12,7 @@ import android.widget.LinearLayout
import android.widget.TextView
import com.yidianling.common.tools.LogUtil
import com.yidianling.home.R
import com.yidianling.home.event.HomeImpl
import com.yidianling.home.event.IHomeBaseEvent
import com.yidianling.home.model.bean.HomeConfideBean
import com.yidianling.home.model.bean.HomeHeaderBean
......@@ -24,7 +25,7 @@ import kotlinx.android.synthetic.xlzx.home_module_confide_view.view.*
* @Company 壹点灵
* @date 2019/02/13
*/
class HomeConfideView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
class HomeConfideView(private val mContext: Context, private var homeEvent: HomeImpl?) :
LinearLayout(mContext) {
private var mLastPosition: Int = 0
/**
......
......@@ -132,7 +132,7 @@ class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterImpl>()
}
private fun initAdapter() {
mPresenter?.localHomeData(this.context)
mPresenter?.localHomeData(this.context, "home_data.json")
adapter = YdlHomeAdapter(context, homeEvent!!, ArrayList())
val layoutManager = LinearLayoutManager(context)
home_module_fragment_recycler.layoutManager = layoutManager
......
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