Commit af81f135 by 徐健

back

parent 263c8326
......@@ -47,7 +47,8 @@ class RecommendListView : LinearLayout {
}
private var mContext: Context? = null
private var mSceneSpecialTopicList = ArrayList<ExpertSearchRecommandBean>() // viewPager的所有item数据
private var mSceneSpecialTopicList =
ArrayList<ExpertSearchRecommandBean>() // viewPager的所有item数据
private var mViewPagerList = ArrayList<LinearLayout>() //viewPager的数据
private var mDoctorSpecialTopicsList = ArrayList<ExpertSearchBigShotBean>() //viewPager的数据
private var minHeight: Int = 0 // viewPager最小高度
......@@ -88,14 +89,14 @@ class RecommendListView : LinearLayout {
if (it.sceneSpecialTopics == null || it.sceneSpecialTopics.size == 0) {
recommendViewPager.visibility = View.GONE
recommendViewPagerIndicator.visibility = View.GONE
}else {
} else {
mSceneSpecialTopicList.addAll(it.sceneSpecialTopics)
recommendViewPager.visibility = View.VISIBLE
recommendViewPagerIndicator.visibility = View.VISIBLE
}
if (it.doctorSpecialTopics == null || it.doctorSpecialTopics.size == 0) {
itemListView.visibility = View.GONE
}else {
} else {
mDoctorSpecialTopicsList.addAll(it.doctorSpecialTopics)
itemListView.visibility = View.VISIBLE
}
......@@ -132,7 +133,8 @@ class RecommendListView : LinearLayout {
/**
* 渲染第一页数据
*/
val firstPagerHeight = RxImageTool.dp2px(60f * (getMinData(mSceneSpecialTopicList.size + 1, 4 + 1) / 2))
val firstPagerHeight =
RxImageTool.dp2px(60f * (getMinData(mSceneSpecialTopicList.size + 1, 4 + 1) / 2))
val firstPager = getLinearLayout(
mContext!!,
firstPagerHeight, VERTICAL
......@@ -155,7 +157,8 @@ class RecommendListView : LinearLayout {
/**
* 渲染第二页数据
*/
val secondPagerHeight = RxImageTool.dp2px(60f * ((mSceneSpecialTopicList.size - 4 + 1) / 2))
val secondPagerHeight =
RxImageTool.dp2px(60f * ((mSceneSpecialTopicList.size - 4 + 1) / 2))
maxHeight = secondPagerHeight + RxImageTool.dp2px(11f)
if (mSceneSpecialTopicList.size > 4) {
val secondPager = getLinearLayout(
......@@ -180,7 +183,12 @@ class RecommendListView : LinearLayout {
recommendViewPager.adapter = RecommendViewPagerAdapter()
recommendViewPager.currentItem = 0
setSelectedIndex(0) // 默认为左边选中
if (mSceneSpecialTopicList.size < 4) {
setOnlyOnePage()
} else {
setSelectedIndex(0) // 默认为左边选中
}
addListener()
}
......@@ -229,6 +237,13 @@ class RecommendListView : LinearLayout {
}
}
private fun setOnlyOnePage() {
leftIndicator.layoutParams = LayoutParams(dp_15, dp_5)
leftIndicator.setBackgroundResource(R.drawable.consultant_indicator_selected)
rightIndicator.visibility = View.GONE
}
private fun getMinData(a: Int, b: Int): Int {
return if (a < b) a else b
}
......@@ -313,7 +328,11 @@ class RecommendListView : LinearLayout {
}
mDoctorSpecialTopicsList.size == 3 -> {
val mView = BigShotThreeView(mContext!!)
mView.setUrl(mDoctorSpecialTopicsList[0], mDoctorSpecialTopicsList[1], mDoctorSpecialTopicsList[2])
mView.setUrl(
mDoctorSpecialTopicsList[0],
mDoctorSpecialTopicsList[1],
mDoctorSpecialTopicsList[2]
)
itemListView.addView(mView)
}
mDoctorSpecialTopicsList.size == 4 -> {
......@@ -335,7 +354,11 @@ class RecommendListView : LinearLayout {
mView.layoutParams = params
val mView1 = BigShotTwoView(mContext!!)
mView.setUrl(mDoctorSpecialTopicsList[0], mDoctorSpecialTopicsList[1], mDoctorSpecialTopicsList[2])
mView.setUrl(
mDoctorSpecialTopicsList[0],
mDoctorSpecialTopicsList[1],
mDoctorSpecialTopicsList[2]
)
mView1.setUrl(mDoctorSpecialTopicsList[3], mDoctorSpecialTopicsList[4])
itemListView.addView(mView)
itemListView.addView(mView1)
......@@ -347,8 +370,16 @@ class RecommendListView : LinearLayout {
mView.layoutParams = params
val mView1 = BigShotThreeView(mContext!!)
mView.setUrl(mDoctorSpecialTopicsList[0], mDoctorSpecialTopicsList[1], mDoctorSpecialTopicsList[2])
mView1.setUrl(mDoctorSpecialTopicsList[3], mDoctorSpecialTopicsList[4], mDoctorSpecialTopicsList[5])
mView.setUrl(
mDoctorSpecialTopicsList[0],
mDoctorSpecialTopicsList[1],
mDoctorSpecialTopicsList[2]
)
mView1.setUrl(
mDoctorSpecialTopicsList[3],
mDoctorSpecialTopicsList[4],
mDoctorSpecialTopicsList[5]
)
itemListView.addView(mView)
itemListView.addView(mView1)
}
......
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