Commit 0b3f990c by 万齐军

feature: 倾诉2.0首页改版

parent c4202080
......@@ -4,12 +4,14 @@ import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.ydl.confide.R
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.config.IConfideHomeConfig
import com.ydl.confide.home.contract.IConfideHomeContract
import com.ydl.confide.home.event.IConfideHomeEvent
import com.ydl.confide.home.widget.*
import com.ydl.ydlcommon.utils.DisplayUtils
/**
* @author yuanwai
......@@ -73,17 +75,26 @@ class ConfideHomeAdapter(private val mContext: Context,
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
when (viewType) {
//banner
IConfideHomeConfig.TYPE_BANNER -> {
return BannerViewHolder(ConfideHomeBannerView(parent.context, confideHomeEvent))
}
// IConfideHomeConfig.TYPE_BANNER -> {
// return BannerViewHolder(ConfideHomeBannerView(parent.context, confideHomeEvent))
// }
//最近倾诉
IConfideHomeConfig.TYPE_RECENTLY_CONFIDED -> {
return ConsultViewHolder(ConfideHomeRecentView(parent.context, confideHomeEvent))
// return ConsultViewHolder(ConfideHomeRecentView(parent.context, confideHomeEvent))
val recyclerView = RecyclerView(parent.context)
recyclerView.layoutParams = ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = DisplayUtils.dip2px(parent.context, 4F)
rightMargin = DisplayUtils.dip2px(parent.context, 4F)
}
return RecentConfideHolder(recyclerView)
}
//分类
IConfideHomeConfig.TYPE_CATEGORY -> {
return CategoryViewHolder(ConfideHomeCategoryView(parent.context, confideHomeEvent, confideHomeView))
}
// IConfideHomeConfig.TYPE_CATEGORY -> {
// return CategoryViewHolder(ConfideHomeCategoryView(parent.context, confideHomeEvent, confideHomeView))
// }
//筛选模块
IConfideHomeConfig.TYPE_RECOMMEND_FILTER -> {
return FilterViewHolder(ConfideHomeFilterView(parent.context, confideHomeView))
......@@ -92,6 +103,17 @@ class ConfideHomeAdapter(private val mContext: Context,
IConfideHomeConfig.TYPE_RECOMMEND -> {
return RecommendViewHolder(ConfideHomeRecommendView(confideHomeView, parent.context, confideHomeEvent))
}
IConfideHomeConfig.TYPE_VIDEO_SHOW -> {
val recyclerView = RecyclerView(parent.context)
recyclerView.layoutParams = ViewGroup.MarginLayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = DisplayUtils.dip2px(parent.context, 6F)
rightMargin = DisplayUtils.dip2px(parent.context, 6F)
}
return VideoShowHolder(recyclerView)
}
// //听声寻人
// IConfideHomeConfig.TYPE_SOUND -> {
//// return ConfideHomeListenAndFoundViewHolder(ConfideHomeListenAndFoundView(parent.context, confideHomeEvent))
......@@ -103,25 +125,36 @@ class ConfideHomeAdapter(private val mContext: Context,
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) =
if (holder is BannerViewHolder && null != holder.bannerView) {
/*if (holder is BannerViewHolder && null != holder.bannerView) {
//banner
holder.bannerView!!.initData(mListData!![position])
} else if (holder is CategoryViewHolder && null != holder.categoryView) {
//分类
holder.categoryView!!.initData(mListData!![position])
} else if (holder is FilterViewHolder && null != holder.filterView) {
} else */if (holder is FilterViewHolder && null != holder.filterView) {
mFilterViewHolder = holder
//筛选模块
holder.filterView.initData(mListData!![position])
} else if (holder is ConfideHomeListenAndFoundViewHolder) {
//听声寻人
// holder.confideHomeListenAndFoundView!!.initData(mListData!![position])
} else if (holder is ConsultViewHolder && null != holder.consultView) {
//最近倾诉
holder.consultView!!.initData(mListData!![position])
} else if (holder is RecentConfideHolder) {
//最近倾诉
holder.rv.layoutManager =
LinearLayoutManager(holder.itemView.context, RecyclerView.HORIZONTAL, false)
val recentBody = mListData!![position].body
val data = recentBody?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
holder.rv.adapter = RecentConfideAdapter(data)
// holder.consultView!!.initData(mListData!![position])
} else if (holder is RecommendViewHolder && null != mListData!![position] && null != mListData!![position].body && !mListData!![position].body!!.isEmpty()) {
//为你推荐
holder.confideHomeRecommendView.initData(mListData!![position].body!![0], position, mListData!![position].recommendId)
} else if (holder is VideoShowHolder) {
holder.rv.layoutManager =
LinearLayoutManager(holder.itemView.context, RecyclerView.HORIZONTAL, false)
val recentBody = mListData!![position].body
val data = recentBody?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
holder.rv.adapter = VideoShowAdapter(data)
} else if (holder is EmptyViewHolder) {
} else {
......@@ -184,4 +217,6 @@ class ConfideHomeAdapter(private val mContext: Context,
view = itemView
}
}
class VideoShowHolder(val rv: RecyclerView) : RecyclerView.ViewHolder(rv)
class RecentConfideHolder(val rv: RecyclerView) : RecyclerView.ViewHolder(rv)
}
\ No newline at end of file
package com.ydl.confide.home.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ObservableField
import androidx.recyclerview.widget.RecyclerView
import com.ydl.confide.R
import com.ydl.confide.databinding.ItemConfideHomeRecentBinding
import com.ydl.confide.databinding.ItemVideoShowBinding
import com.ydl.confide.home.bean.ConfideHomeBodyBean
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.intro.BindingViewHolder
class VideoShowAdapter(val data: List<ItemVideoShowViewModel>) :
RecyclerView.Adapter<BindingViewHolder<ItemVideoShowBinding>>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): BindingViewHolder<ItemVideoShowBinding> {
val layoutInflater = LayoutInflater.from(parent.context)
val binding =
DataBindingUtil.inflate<ItemVideoShowBinding>(layoutInflater, R.layout.item_video_show, parent, false)
return BindingViewHolder(binding)
}
override fun onBindViewHolder(holder: BindingViewHolder<ItemVideoShowBinding>, position: Int) {
holder.binding.item = data[position]
}
override fun getItemCount() = data.size
}
class RecentConfideAdapter(val data: List<ItemVideoShowViewModel>) :
RecyclerView.Adapter<BindingViewHolder<ItemConfideHomeRecentBinding>>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): BindingViewHolder<ItemConfideHomeRecentBinding> {
val layoutInflater = LayoutInflater.from(parent.context)
val binding =
DataBindingUtil.inflate<ItemConfideHomeRecentBinding>(
layoutInflater,
R.layout.item_confide_home_recent,
parent,
false
)
return BindingViewHolder(binding)
}
override fun onBindViewHolder(holder: BindingViewHolder<ItemConfideHomeRecentBinding>, position: Int) {
holder.binding.item = data[position]
}
override fun getItemCount() = data.size
}
class ItemVideoShowViewModel {
val name = ObservableField<String>("")
val coverUrl = ObservableField<String>("")
val videoCoverUrl = ObservableField<String>("")
val state = ObservableField<String>("")
}
internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoShowViewModel {
name.set(bean.confidedName)
coverUrl.set(bean.confidedIcon/*coverPicture*/)
videoCoverUrl.set(bean.confidedIcon/*coverVideoPicture*/)
state.set(bean.confideLine.toString())
return this
}
......@@ -50,6 +50,9 @@ data class ConfideHomeBodyBean(
val couponMoney : String?,
//新用户优惠文案
val couponText : String?,
val videoUrl: String?,
val coverVideoPicture: String?,
val coverPicture: String?,
/**
* banner数据
*/
......
......@@ -21,6 +21,7 @@ interface IConfideHomeConfig{
const val TYPE_SOUND = 6
const val TYPE_CONSULTANT = 7
const val TYPE_FOOTER = 999
const val TYPE_VIDEO_SHOW = 8
/**
* section id. 与上面相对应
*/
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:id="@+id/rl_confide_title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/confide_common_bg"
android:id="@+id/rl_confide_title_layout"
>
android:orientation="horizontal">
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ll_bar_root"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp">
android:layout_height="48dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/confide_back"/>
android:scaleType="center"
android:src="@drawable/confide_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textSize="17dp"
android:text="@string/confide_title"
android:textColor="#FFFFFF"
android:text="@string/confide_title"/>
<ImageView
android:textSize="17dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/img_mine"
android:layout_width="wrap_content"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/confide_mine"/>
</LinearLayout>
android:drawableTop="@drawable/ic_action_confide_order"
android:drawablePadding="4dp"
android:gravity="center"
android:text="订单"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/img_customer"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/img_customer"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableTop="@drawable/ic_action_confide_customer"
android:drawablePadding="4dp"
android:gravity="center"
android:text="客服"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/img_help"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/img_help"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableTop="@drawable/ic_action_confide_help"
android:drawablePadding="4dp"
android:gravity="center"
android:text="帮助"
android:textColor="@color/_9"
android:textSize="7sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="item"
type="com.ydl.confide.home.adapter.ItemVideoShowViewModel" />
</data>
<androidx.cardview.widget.CardView
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="6dp"
app:cardElevation="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:imageUrl="@{item.coverUrl}" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="10dp"
android:text="@{item.name}"
android:textColor="@color/white"
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginBottom="2dp"
android:text="@{item.state}"
android:textColor="@color/white"
android:textSize="7sp" />
</androidx.cardview.widget.CardView>
</layout>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="item"
type="com.ydl.confide.home.adapter.ItemVideoShowViewModel" />
</data>
<androidx.cardview.widget.CardView
android:layout_width="180dp"
android:layout_height="140dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:text="@{item.name}"
android:textColor="@color/white"
android:textSize="15sp" />
<ImageView
android:layout_width="33dp"
android:layout_height="33dp"
android:layout_gravity="center"
android:src="@drawable/ic_video_play"
app:imageUrl="@{item.videoCoverUrl}" />
</androidx.cardview.widget.CardView>
</layout>
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