聊天历史选择器
This commit is contained in:
parent
ad06ee3411
commit
cfee7191c8
|
|
@ -6,6 +6,7 @@ import kotlinx.parcelize.Parcelize
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class ChatHistory(
|
data class ChatHistory(
|
||||||
var id: Int? = 0,
|
var id: Int? = 0,
|
||||||
|
var imgUrl: String?,
|
||||||
var time: Long,
|
var time: Long,
|
||||||
var describle: String
|
var describle: String
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,11 @@ import com.remax.visualnovel.R
|
||||||
import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding
|
import com.remax.visualnovel.databinding.LayoutChatMenuViewBinding
|
||||||
import com.remax.visualnovel.entity.response.ChatBackground
|
import com.remax.visualnovel.entity.response.ChatBackground
|
||||||
import com.remax.visualnovel.entity.response.ChatBubble
|
import com.remax.visualnovel.entity.response.ChatBubble
|
||||||
|
import com.remax.visualnovel.entity.response.ChatHistory
|
||||||
import com.remax.visualnovel.entity.response.ChatMode
|
import com.remax.visualnovel.entity.response.ChatMode
|
||||||
import com.remax.visualnovel.entity.response.ChatSound
|
import com.remax.visualnovel.entity.response.ChatSound
|
||||||
import com.remax.visualnovel.ui.chat.ui.expandableSelector.SelectorItem
|
import com.remax.visualnovel.ui.chat.ui.expandableSelector.SelectorItem
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
class ChatSettingView @JvmOverloads constructor(
|
class ChatSettingView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|
@ -34,6 +36,7 @@ class ChatSettingView @JvmOverloads constructor(
|
||||||
initSoundSelectorView()
|
initSoundSelectorView()
|
||||||
initBubbleSelectView()
|
initBubbleSelectView()
|
||||||
initBackgroundSelectView()
|
initBackgroundSelectView()
|
||||||
|
initHistoryListView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -221,4 +224,38 @@ class ChatSettingView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun initHistoryListView() {
|
||||||
|
val items = listOf(
|
||||||
|
ChatHistory(
|
||||||
|
imgUrl = "",
|
||||||
|
time = Date().time - 3600*100*1,
|
||||||
|
describle = "上次聊天记录 11111",
|
||||||
|
),
|
||||||
|
ChatHistory(
|
||||||
|
imgUrl = "",
|
||||||
|
time = Date().time - 3600*100*2,
|
||||||
|
describle = "上次聊天记录 2222",
|
||||||
|
),
|
||||||
|
ChatHistory(
|
||||||
|
imgUrl = "",
|
||||||
|
time = Date().time - 3600*100*3,
|
||||||
|
describle = "上次聊天记录 333",
|
||||||
|
),
|
||||||
|
ChatHistory(
|
||||||
|
imgUrl = "",
|
||||||
|
time = Date().time - 3600*100*4,
|
||||||
|
describle = "上次聊天记录 444",
|
||||||
|
),ChatHistory(
|
||||||
|
imgUrl = "",
|
||||||
|
time = Date().time - 3600*100*5,
|
||||||
|
describle = "上次聊天记录 5555",
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
mBinding.historySelectView.setItems(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.remax.visualnovel.ui.chat.ui.expandableSelector
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.drake.brv.annotaion.DividerOrientation
|
||||||
|
import com.drake.brv.utils.bindingAdapter
|
||||||
|
import com.drake.brv.utils.divider
|
||||||
|
import com.drake.brv.utils.grid
|
||||||
|
import com.drake.brv.utils.linear
|
||||||
|
import com.drake.brv.utils.models
|
||||||
|
import com.drake.brv.utils.setup
|
||||||
|
import com.remax.visualnovel.R
|
||||||
|
import com.remax.visualnovel.databinding.LayoutItemSettingHistoryBinding
|
||||||
|
import com.remax.visualnovel.databinding.LayoutSettingBgSubViewBinding
|
||||||
|
import com.remax.visualnovel.entity.response.ChatHistory
|
||||||
|
import com.remax.visualnovel.extension.glide.load
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
|
|
||||||
|
class ExpandHistorySubView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
defStyleAttr: Int = 0
|
||||||
|
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||||
|
private lateinit var items: List<ChatHistory>
|
||||||
|
private var mBinding: LayoutSettingBgSubViewBinding
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
mBinding = LayoutSettingBgSubViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
|
with(mBinding) {
|
||||||
|
initRv(itemsRv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initRv(itemsRv: RecyclerView) {
|
||||||
|
itemsRv.linear()
|
||||||
|
.divider {
|
||||||
|
setDivider(10, true)
|
||||||
|
orientation = DividerOrientation.VERTICAL
|
||||||
|
}.setup {
|
||||||
|
addType<ChatHistory>(R.layout.layout_item_setting_history)
|
||||||
|
|
||||||
|
onClick(R.id.root) {
|
||||||
|
itemsRv.bindingAdapter.models?.filterIsInstance<ChatHistory>()?.forEach { item ->
|
||||||
|
openChatHistory(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onBind {
|
||||||
|
val item = getModel<ChatHistory>()
|
||||||
|
with(getBinding<LayoutItemSettingHistoryBinding>()) {
|
||||||
|
if (!item.imgUrl.isNullOrEmpty()) {
|
||||||
|
ivActorAvatar.load(item.imgUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
tvChatTime.text = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.time)
|
||||||
|
tvChatDes.text = item.describle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setItems(newItems: List<ChatHistory>) {
|
||||||
|
items = newItems
|
||||||
|
mBinding.itemsRv.models = items
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openChatHistory(history: ChatHistory) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -275,6 +275,11 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginTop="10dp" >
|
android:layout_marginTop="10dp" >
|
||||||
|
<com.remax.visualnovel.ui.chat.ui.expandableSelector.ExpandHistorySubView
|
||||||
|
android:id="@+id/history_select_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenRelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:backgroundColorToken="@string/color_chat_setting_item_bg"
|
||||||
|
app:radiusToken="@string/radius_l"
|
||||||
|
android:padding="@dimen/dp_12" >
|
||||||
|
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenImageView
|
||||||
|
android:id="@+id/iv_actor_avatar"
|
||||||
|
android:layout_width="@dimen/dp_25"
|
||||||
|
android:layout_height="@dimen/dp_25"
|
||||||
|
android:layout_centerVertical="true" />
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenImageView
|
||||||
|
android:id="@+id/arrow"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:src="@mipmap/setting_arrow_right"/>
|
||||||
|
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp_8"
|
||||||
|
android:layout_toStartOf="@+id/arrow"
|
||||||
|
android:layout_toEndOf="@+id/iv_actor_avatar"
|
||||||
|
>
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||||
|
android:id="@+id/tv_chat_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/sp_12"
|
||||||
|
android:textColor="@color/gray9"
|
||||||
|
android:textStyle="normal"/>
|
||||||
|
|
||||||
|
<com.remax.visualnovel.widget.uitoken.view.UITokenTextView
|
||||||
|
android:id="@+id/tv_chat_des"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_6"
|
||||||
|
android:textSize="@dimen/sp_14"
|
||||||
|
android:textColor="@color/gray6"
|
||||||
|
android:textStyle="normal"/>
|
||||||
|
|
||||||
|
</com.remax.visualnovel.widget.uitoken.view.UITokenLinearLayout>
|
||||||
|
|
||||||
|
</com.remax.visualnovel.widget.uitoken.view.UITokenRelativeLayout>
|
||||||
|
|
@ -190,6 +190,7 @@
|
||||||
<color name="chat_send_bg">#ff565563</color>
|
<color name="chat_send_bg">#ff565563</color>
|
||||||
<color name="gray3">#ff333333</color>
|
<color name="gray3">#ff333333</color>
|
||||||
<color name="gray6">#ff666666</color>
|
<color name="gray6">#ff666666</color>
|
||||||
|
<color name="gray9">#ff999999</color>
|
||||||
<color name="grayf6">#fff6f6f6</color>
|
<color name="grayf6">#fff6f6f6</color>
|
||||||
|
|
||||||
<!-- chat settings -->
|
<!-- chat settings -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue