@@ -21,7 +21,7 @@ import com.bihe0832.android.lib.utils.os.DisplayUtil
2121private val mAutoShowMessageList = mutableListOf<String >()
2222
2323fun BaseActivity.addMessageAction (messageView : ImageView , unreadView : TextViewWithBackground ) {
24- AAFMessageManager .getMessageLiveData().value? .let { updateMessageMenuAndShowFace(it, this , unreadView) }
24+ AAFMessageManager .getMessageLiveData().value.let { updateMessageMenuAndShowFace(it, this , unreadView) }
2525 AAFMessageManager .getMessageLiveData().observe(this ) { t ->
2626 updateMessageMenuAndShowFace(t, this , unreadView)
2727 }
@@ -35,17 +35,22 @@ fun BaseActivity.addMessageAction(messageView: ImageView, unreadView: TextViewWi
3535}
3636
3737@Synchronized
38- fun updateMessageMenuAndShowFace (noticeList : List <MessageInfoItem >, activity : BaseActivity , unreadView : TextViewWithBackground ) {
39- noticeList.filter { ! it.hasRead() }.let {
40- if (it.isNotEmpty()) {
41- unreadView.changeStatusWithUnreadMsg(it.size, DisplayUtil .dip2px(activity, 8f ))
42- } else {
43- unreadView.changeStatusWithUnreadMsg(- 1 , DisplayUtil .dip2px(activity, 8f ))
38+ fun updateMessageMenuAndShowFace (noticeList : List <MessageInfoItem >? , activity : BaseActivity , unreadView : TextViewWithBackground ) {
39+ if (noticeList.isNullOrEmpty()) {
40+ unreadView.changeStatusWithUnreadMsg(- 1 , DisplayUtil .dip2px(activity, 8f ))
41+ } else {
42+ noticeList.filter { ! it.hasRead() }.let {
43+ if (it.isNotEmpty()) {
44+ unreadView.changeStatusWithUnreadMsg(it.size, DisplayUtil .dip2px(activity, 8f ))
45+ } else {
46+ unreadView.changeStatusWithUnreadMsg(- 1 , DisplayUtil .dip2px(activity, 8f ))
47+ }
4448 }
45- }
4649
47- noticeList.distinctBy { it.messageID }.filter { ! mAutoShowMessageList.contains(it.messageID) && AAFMessageManager .canShowFace(it, false ) }.forEach {
48- mAutoShowMessageList.add(it.messageID)
49- AAFMessageManager .showMessage(activity, it, true )
50+ noticeList.distinctBy { it.messageID }.filter { ! mAutoShowMessageList.contains(it.messageID) && AAFMessageManager .canShowFace(it, false ) }.forEach {
51+ mAutoShowMessageList.add(it.messageID)
52+ AAFMessageManager .showMessage(activity, it, true )
53+ }
5054 }
55+
5156}
0 commit comments