|
|
@@ -32,7 +32,7 @@ import com.scwang.smart.refresh.layout.constant.RefreshState
|
|
|
import com.scwang.smart.refresh.layout.simple.SimpleMultiListener
|
|
|
|
|
|
@RouterUri(path = [Message.Conversation.LIST], desc = "会话列表")
|
|
|
-class ConversationListFragment: BaseFragment(R.layout.fragment_conversationlist), BaseAdapter.OnItemClickListener,
|
|
|
+class ConversationListFragment: BaseFragment(R.layout.fragment_conversationlist),
|
|
|
IViewProviderListener<BaseUiConversation> {
|
|
|
val binding by viewBinding(FragmentConversationlistBinding::bind)
|
|
|
private var adapter: ConversationListAdapter = ConversationListAdapter(this)
|
|
|
@@ -42,7 +42,6 @@ class ConversationListFragment: BaseFragment(R.layout.fragment_conversationlist)
|
|
|
|
|
|
override fun initViews() {
|
|
|
super.initViews()
|
|
|
- adapter.setItemClickListener(this)
|
|
|
val layoutManager: LinearLayoutManager = FixedLinearLayoutManager(
|
|
|
activity
|
|
|
)
|
|
|
@@ -155,32 +154,27 @@ class ConversationListFragment: BaseFragment(R.layout.fragment_conversationlist)
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- override fun onItemClick(view: View, holder: ViewHolder, position: Int) {
|
|
|
- if(position < 0 || position >= adapter.data.size) {
|
|
|
- return
|
|
|
- }
|
|
|
- val baseUiConversation: BaseUiConversation = adapter.getItem(position)
|
|
|
- val conversationIdentifier = baseUiConversation.conversationIdentifier ?: return
|
|
|
- val targetId = conversationIdentifier.targetId.toLongOrNull() ?: return
|
|
|
- val act = activity ?: return
|
|
|
- Router.build(act, Message.Conversation.PATH)
|
|
|
- .putExtra(Message.Common.EXTRA_TO_UID, targetId)
|
|
|
- .putExtra(Message.Common.EXTRA_CONVERSATION_TYPE, conversationIdentifier.type.value)
|
|
|
- .start()
|
|
|
- }
|
|
|
-
|
|
|
- override fun onItemLongClick(view: View, holder: ViewHolder, position: Int): Boolean {
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
override fun onViewClick(clickType: Int, data: BaseUiConversation) {
|
|
|
- if (clickType == ConversationClickType.USER_PORTRAIT_CLICK) {
|
|
|
- onUserPortraitClick(data)
|
|
|
- } else if (clickType == ConversationClickType.DELETE_CLICK) {
|
|
|
- onDeleteClick(data)
|
|
|
- } else {
|
|
|
- conversationListViewModel.onViewClick(clickType, data)
|
|
|
+ when (clickType) {
|
|
|
+ ConversationClickType.CONTENT_CLICK -> {
|
|
|
+ val conversationIdentifier = data.conversationIdentifier ?: return
|
|
|
+ val targetId = conversationIdentifier.targetId.toLongOrNull() ?: return
|
|
|
+ val act = activity ?: return
|
|
|
+ Router.build(act, Message.Conversation.PATH)
|
|
|
+ .putExtra(Message.Common.EXTRA_TO_UID, targetId)
|
|
|
+ .putExtra(Message.Common.EXTRA_CONVERSATION_TYPE, conversationIdentifier.type.value)
|
|
|
+ .start()
|
|
|
+ }
|
|
|
+ ConversationClickType.USER_PORTRAIT_CLICK -> {
|
|
|
+ onUserPortraitClick(data)
|
|
|
+ }
|
|
|
+ ConversationClickType.DELETE_CLICK -> {
|
|
|
+ onDeleteClick(data)
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ conversationListViewModel.onViewClick(clickType, data)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|