|
@@ -11,6 +11,7 @@ import android.text.style.ImageSpan
|
|
import android.view.LayoutInflater
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
|
|
+import android.widget.ImageView
|
|
import android.widget.TextView
|
|
import android.widget.TextView
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.core.content.ContextCompat
|
|
import androidx.core.content.ContextCompat
|
|
@@ -25,6 +26,8 @@ import com.swago.baseswago.model.im.FollowSuccessMsgBean
|
|
import com.swago.baseswago.model.im.IMLevelUpMsgBean
|
|
import com.swago.baseswago.model.im.IMLevelUpMsgBean
|
|
import com.swago.baseswago.model.im.RoomChatMsgBean
|
|
import com.swago.baseswago.model.im.RoomChatMsgBean
|
|
import com.swago.baseswago.model.im.UserJoinRoomBean
|
|
import com.swago.baseswago.model.im.UserJoinRoomBean
|
|
|
|
+import com.swago.baseswago.util.BitmapUtils
|
|
|
|
+import com.swago.baseswago.util.UserInfo
|
|
import com.swago.formatAr
|
|
import com.swago.formatAr
|
|
import com.swago.room.R
|
|
import com.swago.room.R
|
|
import com.swago.room.adapter.bitmap.CenterAlignImageSpan
|
|
import com.swago.room.adapter.bitmap.CenterAlignImageSpan
|
|
@@ -45,9 +48,13 @@ class RoomChatAdapter :
|
|
*/
|
|
*/
|
|
private val iconBitmapCachePool: HashMap<String, Bitmap> = HashMap()
|
|
private val iconBitmapCachePool: HashMap<String, Bitmap> = HashMap()
|
|
private val localImageKey = ArrayList<String>()
|
|
private val localImageKey = ArrayList<String>()
|
|
|
|
+ private val badgeBitmap by lazy {
|
|
|
|
+ BitmapUtils.getBitmapFromPath(UserInfo.getUserInfo()?.badge_special)
|
|
|
|
+ }
|
|
|
|
|
|
companion object {
|
|
companion object {
|
|
const val LEVEL_KEY = "level"
|
|
const val LEVEL_KEY = "level"
|
|
|
|
+ const val BADGE_KEY = "badge"
|
|
const val PRETTY_KEY = "pretty"//靓号
|
|
const val PRETTY_KEY = "pretty"//靓号
|
|
const val VIP_KEY = "vip"//每日首冲
|
|
const val VIP_KEY = "vip"//每日首冲
|
|
const val IS_OFFICIAL = "official"
|
|
const val IS_OFFICIAL = "official"
|
|
@@ -60,6 +67,7 @@ class RoomChatAdapter :
|
|
|
|
|
|
init {
|
|
init {
|
|
localImageKey.add(LEVEL_KEY)
|
|
localImageKey.add(LEVEL_KEY)
|
|
|
|
+ localImageKey.add(BADGE_KEY)
|
|
localImageKey.add(PRETTY_KEY)
|
|
localImageKey.add(PRETTY_KEY)
|
|
localImageKey.add(VIP_KEY)
|
|
localImageKey.add(VIP_KEY)
|
|
localImageKey.add(IS_OFFICIAL)
|
|
localImageKey.add(IS_OFFICIAL)
|
|
@@ -366,6 +374,13 @@ class RoomChatAdapter :
|
|
.append("'> ")
|
|
.append("'> ")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (item is UserJoinRoomBean && badgeBitmap != null) {
|
|
|
|
+ count++
|
|
|
|
+ sb.append("<img src='" + "file:///xx/")
|
|
|
|
+ .append(BADGE_KEY).append(".png")
|
|
|
|
+ .append("'> ")
|
|
|
|
+ }
|
|
|
|
+
|
|
count++
|
|
count++
|
|
sb.append("<img src='" + "file:///xx/")
|
|
sb.append("<img src='" + "file:///xx/")
|
|
.append(LEVEL_KEY).append(".png")
|
|
.append(LEVEL_KEY).append(".png")
|
|
@@ -526,7 +541,14 @@ class RoomChatAdapter :
|
|
end,
|
|
end,
|
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
)
|
|
)
|
|
- }else {
|
|
|
|
|
|
+ }else if (imageSpan.source != null && imageSpan!!.source!!.contains(BADGE_KEY)) {
|
|
|
|
+ span.setSpan(
|
|
|
|
+ setBadge(helper.itemView as ViewGroup),
|
|
|
|
+ start,
|
|
|
|
+ end,
|
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
|
+ )
|
|
|
|
+ }else {
|
|
span.setSpan(newImageSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
span.setSpan(newImageSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
}
|
|
}
|
|
span.removeSpan(imageSpan)
|
|
span.removeSpan(imageSpan)
|
|
@@ -723,6 +745,11 @@ class RoomChatAdapter :
|
|
return CustomImageSpan(mContext, bm, CustomImageSpan.ALIGN_FONTCENTER)
|
|
return CustomImageSpan(mContext, bm, CustomImageSpan.ALIGN_FONTCENTER)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun setBadge(viewGroup: ViewGroup): CustomImageSpan {
|
|
|
|
+ val imageView = ImageView(mContext)
|
|
|
|
+ viewGroup.addView(imageView)
|
|
|
|
+ return CustomImageSpan(mContext, badgeBitmap, CustomImageSpan.ALIGN_FONTCENTER)
|
|
|
|
+ }
|
|
|
|
|
|
private fun setLevel(iSenderLevel: Int, viewGroup: ViewGroup): CustomImageSpan {
|
|
private fun setLevel(iSenderLevel: Int, viewGroup: ViewGroup): CustomImageSpan {
|
|
var level = iSenderLevel.toString()
|
|
var level = iSenderLevel.toString()
|