瀏覽代碼

1、增加空布局;

yzs 4 年之前
父節點
當前提交
d59d7b0659
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      uchat_im/src/main/java/com/shanp/youqi/im/fragment/MessageListOnlyUserFragment.kt

+ 13 - 0
uchat_im/src/main/java/com/shanp/youqi/im/fragment/MessageListOnlyUserFragment.kt

@@ -8,6 +8,7 @@ import com.shanp.youqi.base.rx.EventSubscriber
 import com.shanp.youqi.base.rx.RxBus
 import com.shanp.youqi.common.base.UChatFragment
 import com.shanp.youqi.common.vo.im.ConversationListVo
+import com.shanp.youqi.common.widget.EmptyView
 import com.shanp.youqi.core.event.IMReceivedMessageEvent
 import com.shanp.youqi.core.memory.AppManager
 import com.shanp.youqi.im.R
@@ -38,6 +39,7 @@ class MessageListOnlyUserFragment : UChatFragment() {
 
     private var adapter = MessageListOnlyUserAdapter(null)
     private val messageListDialog: MessageListDialog by lazy { parentFragment as MessageListDialog }
+    private lateinit var emptyView: EmptyView
 
     override fun getLayoutId(): Int = R.layout.im_fragment_message_list_only_user
 
@@ -51,6 +53,11 @@ class MessageListOnlyUserFragment : UChatFragment() {
     }
 
     private fun initRecyclerView() {
+        emptyView = EmptyView(mContext)
+                .setColorStyle(true)
+                .setNoDataTitle("暂无聊天联系人")
+                .setNoDataIconIds(R.drawable.empty_box_bright)
+                .setLayoutType(EmptyView.LayoutType.TYPE_LAYOUT_NO_DATA)
         val manager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
         binding.rcv.itemAnimator = null
         binding.rcv.layoutManager = manager
@@ -152,12 +159,18 @@ class MessageListOnlyUserFragment : UChatFragment() {
                 }
 
                 if (tempData.size > 0) {
+                    adapter.isUseEmpty(false)
                     adapter.addData(tempData)
                 }
                 timeStamp = adapter.data.last().conversation.sentTime
                 binding.srl.setEnableLoadMore(data.size >= count)
                 binding.srl.finishLoadMore()
             } else {
+                if (adapter.itemCount <= 0) {
+                    adapter.isUseEmpty(true)
+                    adapter.emptyView = emptyView
+                    adapter.notifyDataSetChanged()
+                }
                 binding.srl.setEnableLoadMore(false)
                 binding.srl.setNoMoreData(true)
                 binding.srl.finishLoadMore()