Explorar o código

feat: 聊天气泡

tongmengxiao hai 6 meses
pai
achega
b87204c958

+ 1 - 0
baseswago/src/main/java/com/swago/baseswago/UserVm.kt

@@ -47,6 +47,7 @@ class UserVm(application: Application) : BaseViewModel(application) {
             val data = ApiManager.userApi.getUserInfo()
             userInfoLiveData.value = data
             BitmapUtils.loadFile(AppContext.getContext() , data.badge_special)
+            BitmapUtils.loadFile(AppContext.getContext() , data.chat_special)
         }
     }
 

+ 1 - 2
baseswago/src/main/java/com/swago/baseswago/util/BitmapUtils.kt

@@ -25,7 +25,7 @@ object BitmapUtils {
 
     }
 
-    fun loadFile(context: Context, url: String,) {
+    fun loadFile(context: Context, url: String) {
         if (context is Activity){
             if (context.isDestroyed)
                 return
@@ -33,7 +33,6 @@ object BitmapUtils {
         Glide.with(context)
             .asBitmap()
             .load(url)
-            .override(207,60)
             .into(object : CustomTarget<Bitmap>() {
                 override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
                     val path = "${AppContext.getContext().getExternalFilesDir(null)!!.path}/swagoFile"

+ 10 - 0
room/src/main/java/com/swago/room/adapter/RoomChatAdapter.kt

@@ -2,6 +2,7 @@ package com.swago.room.adapter
 
 import android.graphics.Bitmap
 import android.graphics.Color
+import android.graphics.drawable.BitmapDrawable
 import android.os.Build
 import android.text.*
 import android.text.method.LinkMovementMethod
@@ -51,6 +52,12 @@ class RoomChatAdapter :
     private val badgeBitmap by lazy {
         BitmapUtils.getBitmapFromPath(UserInfo.getUserInfo()?.badge_special)
     }
+    private val bubbleChat by lazy {
+        BitmapDrawable(mContext.resources , BitmapUtils.getBitmapFromPath(UserInfo.getUserInfo()?.badge_special))
+    }
+    private val userid by lazy {
+        UserInfo.getUserInfo()?.id
+    }
 
     companion object {
         const val LEVEL_KEY = "level"
@@ -449,6 +456,9 @@ class RoomChatAdapter :
 
                 }
             }
+            if (bubbleChat != null && item.getSenderId() == userid){
+                tvContent.background = bubbleChat
+            }
             tvContent.movementMethod = LinkMovementMethod.getInstance()
             tvContent.highlightColor = Color.TRANSPARENT
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {