|
@@ -11,12 +11,16 @@ import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import android.widget.TextView
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter
|
|
|
import com.chad.library.adapter.base.BaseViewHolder
|
|
|
import com.swago.baseswago.cusview.LiangView
|
|
|
import com.swago.baseswago.cusview.SwagoLevelView
|
|
|
import com.swago.baseswago.im.IRoomChat
|
|
|
import com.swago.baseswago.im.RoomMsgType
|
|
|
+import com.swago.baseswago.model.im.FollowSuccessMsgBean
|
|
|
+import com.swago.baseswago.model.im.RoomChatMsgBean
|
|
|
+import com.swago.baseswago.model.im.UserJoinRoomBean
|
|
|
import com.swago.formatAr
|
|
|
import com.swago.room.R
|
|
|
import com.swago.room.adapter.bitmap.CenterAlignImageSpan
|
|
@@ -41,11 +45,15 @@ class RoomChatAdapter :
|
|
|
companion object {
|
|
|
const val LEVEL_KEY = "level"
|
|
|
const val PRETTY_KEY = "pretty"//靓号
|
|
|
+ const val IS_OFFICIAL = "official"
|
|
|
+ const val IS_SERVICE = "service"
|
|
|
}
|
|
|
|
|
|
init {
|
|
|
localImageKey.add(LEVEL_KEY)
|
|
|
localImageKey.add(PRETTY_KEY)
|
|
|
+ localImageKey.add(IS_OFFICIAL)
|
|
|
+ localImageKey.add(IS_SERVICE)
|
|
|
}
|
|
|
|
|
|
var showUserInfoDialog: ((iChatMsg: IRoomChat) -> Unit)? = null
|
|
@@ -73,6 +81,21 @@ class RoomChatAdapter :
|
|
|
.append("'> ")
|
|
|
}
|
|
|
|
|
|
+ if (item is RoomChatMsgBean&&item.isService==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_SERVICE).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item is RoomChatMsgBean&&item.isOfficial==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_OFFICIAL).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
count++
|
|
|
sb.append("<img src='" + "file:///xx/")
|
|
|
.append(LEVEL_KEY).append(".png")
|
|
@@ -148,6 +171,20 @@ class RoomChatAdapter :
|
|
|
.append("'> ")
|
|
|
}
|
|
|
|
|
|
+ if (item is FollowSuccessMsgBean&&item.isService==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_SERVICE).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item is FollowSuccessMsgBean&&item.isOfficial==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_OFFICIAL).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
count++
|
|
|
sb.append("<img src='" + "file:///xx/")
|
|
|
.append(LEVEL_KEY).append(".png")
|
|
@@ -211,6 +248,20 @@ class RoomChatAdapter :
|
|
|
.append("'> ")
|
|
|
}
|
|
|
|
|
|
+ if (item is UserJoinRoomBean&&item.isService==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_SERVICE).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item is UserJoinRoomBean&&item.isOfficial==1){
|
|
|
+ count++
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
+ .append(IS_OFFICIAL).append(".png")
|
|
|
+ .append("'> ")
|
|
|
+ }
|
|
|
+
|
|
|
count++
|
|
|
sb.append("<img src='" + "file:///xx/")
|
|
|
.append(LEVEL_KEY).append(".png")
|
|
@@ -322,6 +373,20 @@ class RoomChatAdapter :
|
|
|
end,
|
|
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
)
|
|
|
+ } else if(imageSpan.source != null && imageSpan!!.source!!.contains(IS_SERVICE)){
|
|
|
+ span.setSpan(
|
|
|
+ setService(helper.itemView as ViewGroup),
|
|
|
+ start,
|
|
|
+ end,
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
+ )
|
|
|
+ } else if(imageSpan.source != null && imageSpan!!.source!!.contains(IS_OFFICIAL)){
|
|
|
+ span.setSpan(
|
|
|
+ setOfficial(helper.itemView as ViewGroup),
|
|
|
+ start,
|
|
|
+ end,
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
+ )
|
|
|
}else {
|
|
|
span.setSpan(newImageSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
|
}
|
|
@@ -333,6 +398,53 @@ class RoomChatAdapter :
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private fun setService(viewGroup: ViewGroup):CustomImageSpan {
|
|
|
+ var bm = iconBitmapCachePool["service"]
|
|
|
+ if (bm == null) {
|
|
|
+ val view = LayoutInflater.from(mContext)
|
|
|
+ .inflate(R.layout.item_service, viewGroup, false) as ConstraintLayout
|
|
|
+ view.measure(
|
|
|
+ View.MeasureSpec.makeMeasureSpec(
|
|
|
+ (1 shl 30) - 1,
|
|
|
+ View.MeasureSpec.AT_MOST
|
|
|
+ ),
|
|
|
+ View.MeasureSpec.makeMeasureSpec(
|
|
|
+ (1 shl 30) - 1,
|
|
|
+ View.MeasureSpec.AT_MOST
|
|
|
+ )
|
|
|
+ )
|
|
|
+ bm = convertViewToBitmap(view)
|
|
|
+ if (bm != null) {
|
|
|
+ iconBitmapCachePool["service"] = bm
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CustomImageSpan(mContext, bm, CustomImageSpan.ALIGN_FONTCENTER)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun setOfficial(viewGroup: ViewGroup):CustomImageSpan {
|
|
|
+ var bm = iconBitmapCachePool["official"]
|
|
|
+ if (bm == null) {
|
|
|
+ val view = LayoutInflater.from(mContext)
|
|
|
+ .inflate(R.layout.item_official_icon, viewGroup, false) as ConstraintLayout
|
|
|
+ view.measure(
|
|
|
+ View.MeasureSpec.makeMeasureSpec(
|
|
|
+ (1 shl 30) - 1,
|
|
|
+ View.MeasureSpec.AT_MOST
|
|
|
+ ),
|
|
|
+ View.MeasureSpec.makeMeasureSpec(
|
|
|
+ (1 shl 30) - 1,
|
|
|
+ View.MeasureSpec.AT_MOST
|
|
|
+ )
|
|
|
+ )
|
|
|
+ bm = convertViewToBitmap(view)
|
|
|
+ if (bm != null) {
|
|
|
+ iconBitmapCachePool["official"] = bm
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CustomImageSpan(mContext, bm, CustomImageSpan.ALIGN_FONTCENTER)
|
|
|
+ }
|
|
|
+
|
|
|
private fun setPrettyId(senderId: String, viewGroup: ViewGroup): CustomImageSpan {
|
|
|
var bm = iconBitmapCachePool[senderId + "level"]
|
|
|
if (bm == null) {
|
|
@@ -354,7 +466,6 @@ class RoomChatAdapter :
|
|
|
iconBitmapCachePool[senderId + "level"] = bm
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return CustomImageSpan(mContext, bm, CustomImageSpan.ALIGN_FONTCENTER)
|
|
|
}
|
|
|
|