feat:完成房间公聊-头条入口调整
This commit is contained in:
@@ -15,6 +15,7 @@ import com.chwl.app.avroom.adapter.GameMiniMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.game.GameDelegate
|
||||
import com.chwl.app.avroom.game.OnGameStatusChangeListener
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.GameRoomPresenter
|
||||
import com.chwl.app.avroom.view.IGameRoomView
|
||||
@@ -85,6 +86,9 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
|
||||
gameBinding.ivShowMic.setOnClickListener { showMic() }
|
||||
gameBinding.headlineWidget.setOnClickListener {
|
||||
switchMessageLayoutHeight()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@@ -122,22 +126,27 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun setMessagePagerAutoHeight(recyclerView: RecyclerView){
|
||||
private fun setMessagePagerAutoHeight(recyclerView: RecyclerView) {
|
||||
recyclerView.setOnTouchListener(OnTouchListener { v: View?, event: MotionEvent ->
|
||||
if (recyclerView.scrollState == RecyclerView.SCROLL_STATE_IDLE
|
||||
&& event.action == MotionEvent.ACTION_UP
|
||||
) {
|
||||
val layoutParams: ViewGroup.LayoutParams = messagePager.layoutParams
|
||||
val bigHeight = ScreenUtil.dip2px(200f)
|
||||
val littleHeight = ScreenUtil.dip2px(80f)
|
||||
layoutParams.height =
|
||||
if (layoutParams.height == littleHeight) bigHeight else littleHeight
|
||||
messagePager.layoutParams = layoutParams
|
||||
switchMessageLayoutHeight()
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
private fun switchMessageLayoutHeight() {
|
||||
val view = gameBinding.layoutMessage
|
||||
val layoutParams: ViewGroup.LayoutParams = view.layoutParams
|
||||
val bigHeight = ScreenUtil.dip2px(200f)
|
||||
val littleHeight = ScreenUtil.dip2px(80f)
|
||||
layoutParams.height =
|
||||
if (layoutParams.height == littleHeight) bigHeight else littleHeight
|
||||
view.layoutParams = layoutParams
|
||||
}
|
||||
|
||||
private fun showMiniMic() {
|
||||
if (isShowMiniMic) return
|
||||
isShowMiniMic = true
|
||||
@@ -248,5 +257,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RoomOnlineWidget::class.java.simpleName, gameBinding.onlineWidget)
|
||||
registerWidget(RoomHeadlineWidget::class.java.simpleName, gameBinding.headlineWidget)
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget;
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
@@ -134,6 +135,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RoomOnlineWidget.class.getSimpleName(), gameBinding.onlineWidget);
|
||||
registerWidget(RoomHeadlineWidget.class.getSimpleName(), gameBinding.headlineWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
@@ -13,6 +13,7 @@ import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.chwl.app.avroom.dialog.RequestUpMicDialog
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.SingleRoomPresenter
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
@@ -236,6 +237,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RoomOnlineWidget::class.java.simpleName, gameBinding.onlineWidget)
|
||||
registerWidget(RoomHeadlineWidget::class.java.simpleName, gameBinding.headlineWidget)
|
||||
}
|
||||
|
||||
override fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
|
@@ -0,0 +1,105 @@
|
||||
package com.chwl.app.avroom.headline
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomHeadlineWidgetBinding
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
|
||||
class RoomHeadlineWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val binding: RoomHeadlineWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_headline_widget, this, true
|
||||
)
|
||||
|
||||
private var chatRoomClient: ChatRoomClient? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
if (!isInEditMode) {
|
||||
updateHeadline(null)
|
||||
}
|
||||
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
requestCurrentHeadline()
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (message.msgType == MsgTypeEnum.custom) {
|
||||
val attachment: CustomAttachment = (message.attachment as? CustomAttachment) ?: return
|
||||
when (attachment.first) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED -> {
|
||||
when (attachment.second) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB -> {
|
||||
val data = (attachment as? HeadlineChangedAttachment) ?: return
|
||||
updateHeadline(data.headlineData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initChatRoom(chatRoomClient: ChatRoomClient) {
|
||||
// 登录流程:在PublicChatRoomMessageWidget中已经执行了
|
||||
getCompositeDisposable().add(chatRoomClient.messageObservable.subscribe {
|
||||
it.forEach { message ->
|
||||
onReceiveMessage(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateHeadline(data: HeadlineBean?) {
|
||||
val content = data?.content
|
||||
if (data?.isValid() == true && !content.isNullOrEmpty()) {
|
||||
binding.tvHeadlineContent.text = content
|
||||
this.isVisible = true
|
||||
} else {
|
||||
this.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
chatRoomClient = null
|
||||
}
|
||||
}
|
@@ -2,18 +2,10 @@ package com.chwl.app.avroom.public_chat
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomPublicChatMessageWidgetBinding
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.initial.InitialModel
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
@@ -24,12 +16,7 @@ import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum
|
||||
|
||||
class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val binding: RoomPublicChatMessageWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_public_chat_message_widget, this, true
|
||||
)
|
||||
private val messageView: PublicChatMessageView = PublicChatMessageView(context)
|
||||
|
||||
private var chatRoomClient: ChatRoomClient? = null
|
||||
|
||||
@@ -48,6 +35,10 @@ class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
addView(messageView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
|
||||
@@ -57,25 +48,11 @@ class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
requestCurrentHeadline()
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (!filterMessageForMessageList(message)) {
|
||||
binding.messageView.addMessages(message)
|
||||
}
|
||||
if (message.msgType == MsgTypeEnum.custom) {
|
||||
val attachment: CustomAttachment = (message.attachment as? CustomAttachment) ?: return
|
||||
when (attachment.first) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED -> {
|
||||
when (attachment.second) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB -> {
|
||||
val data = (attachment as? HeadlineChangedAttachment) ?: return
|
||||
updateHeadline(data.headlineData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
messageView.addMessages(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,30 +85,13 @@ class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
QueryDirectionEnum.QUERY_OLD,
|
||||
typeEnums
|
||||
).subscribe({
|
||||
binding.messageView.addHistoryMessages(it.reversed())
|
||||
messageView.addHistoryMessages(it.reversed())
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateHeadline(data: HeadlineBean?) {
|
||||
val content = data?.content
|
||||
if (data?.isValid() == true && !content.isNullOrEmpty()) {
|
||||
binding.tvHeadlineContent.text = content
|
||||
binding.tvHeadlineContent.isVisible = true
|
||||
} else {
|
||||
binding.tvHeadlineContent.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun filterMessageForMessageList(message: ChatRoomMessage): Boolean {
|
||||
if (message.msgType == MsgTypeEnum.custom && message.attachment is HeadlineChangedAttachment) {
|
||||
val data = (message.attachment as HeadlineChangedAttachment).headlineData
|
||||
@@ -142,7 +102,7 @@ class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
return false
|
||||
}
|
||||
|
||||
fun getMessageView() = binding.messageView
|
||||
fun getMessageView() = messageView
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
|
BIN
app/src/main/res/drawable-xxhdpi/room_bg_headline.9.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/room_bg_headline.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
@@ -191,15 +191,27 @@
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="@dimen/dp_5" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/bottom_view"
|
||||
android:layout_below="@id/message_indicator"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginBottom="@dimen/dp_10" />
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
android:id="@+id/headline_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.coorchice.library.SuperTextView
|
||||
android:id="@+id/tv_dating_next"
|
||||
|
@@ -144,20 +144,32 @@
|
||||
|
||||
<com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/message_indicator"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_35"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:layout_above="@id/message_pager" />
|
||||
android:layout_above="@id/layout_message"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="@dimen/dp_5" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_above="@id/bottom_view"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginBottom="@dimen/dp_10" />
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
android:id="@+id/headline_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{click}"
|
||||
|
@@ -208,17 +208,29 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/barrier_micro" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_message"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/message_indicator" />
|
||||
app:layout_constraintTop_toBottomOf="@id/message_indicator">
|
||||
|
||||
<com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
android:id="@+id/headline_widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/message_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/input_layout"
|
||||
|
18
app/src/main/res/layout/room_headline_widget.xml
Normal file
18
app/src/main/res/layout/room_headline_widget.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/tv_headline_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:background="@drawable/room_bg_headline"
|
||||
android:paddingHorizontal="@dimen/dp_10"
|
||||
android:paddingTop="@dimen/dp_9"
|
||||
android:paddingBottom="@dimen/dp_9"
|
||||
android:textColor="#FFF6E1"
|
||||
android:textSize="@dimen/dp_13"
|
||||
tools:text="Content" />
|
||||
|
||||
</layout>
|
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:id="@+id/tv_headline_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_33adf4ff_7dp"
|
||||
android:paddingHorizontal="@dimen/dp_10"
|
||||
android:paddingTop="@dimen/dp_9"
|
||||
android:paddingBottom="@dimen/dp_9"
|
||||
android:textColor="#05FFE3"
|
||||
android:textSize="@dimen/dp_13"
|
||||
tools:text="Content" />
|
||||
|
||||
<com.chwl.app.avroom.public_chat.PublicChatMessageView
|
||||
android:id="@+id/message_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
Reference in New Issue
Block a user