|
@@ -1,10 +1,5 @@
|
|
package com.swago.home
|
|
package com.swago.home
|
|
|
|
|
|
-import android.graphics.BitmapFactory
|
|
|
|
-import android.graphics.NinePatch
|
|
|
|
-import android.graphics.drawable.BitmapDrawable
|
|
|
|
-import android.graphics.drawable.Drawable
|
|
|
|
-import android.graphics.drawable.NinePatchDrawable
|
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.text.TextUtils
|
|
import android.text.TextUtils
|
|
import android.view.View
|
|
import android.view.View
|
|
@@ -13,18 +8,17 @@ import androidx.core.content.ContextCompat
|
|
import com.alibaba.android.arouter.facade.annotation.Autowired
|
|
import com.alibaba.android.arouter.facade.annotation.Autowired
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
-import com.google.firebase.firestore.auth.User
|
|
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import com.gyf.immersionbar.ImmersionBar
|
|
import com.gyf.immersionbar.ImmersionBar
|
|
|
|
+import com.opensource.svgaplayer.SVGADrawable
|
|
|
|
+import com.opensource.svgaplayer.SVGAParser
|
|
|
|
+import com.opensource.svgaplayer.SVGAVideoEntity
|
|
import com.swago.baseswago.PersonDataDFragment
|
|
import com.swago.baseswago.PersonDataDFragment
|
|
import com.swago.baseswago.UserVm
|
|
import com.swago.baseswago.UserVm
|
|
import com.swago.baseswago.activity.BaseXActivity
|
|
import com.swago.baseswago.activity.BaseXActivity
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.dialog.ReportBlockDialogFragment
|
|
import com.swago.baseswago.dialog.ReportBlockDialogFragment
|
|
-import com.swago.baseswago.util.AppContext
|
|
|
|
-import com.swago.baseswago.util.BitmapUtils
|
|
|
|
import com.swago.baseswago.util.DianJiuUtil
|
|
import com.swago.baseswago.util.DianJiuUtil
|
|
-import com.swago.baseswago.util.NinePatchChunk
|
|
|
|
import com.swago.baseswago.util.NoDoubleClickListener
|
|
import com.swago.baseswago.util.NoDoubleClickListener
|
|
import com.swago.baseswago.util.SpUtil
|
|
import com.swago.baseswago.util.SpUtil
|
|
import com.swago.baseswago.util.UserInfo
|
|
import com.swago.baseswago.util.UserInfo
|
|
@@ -33,7 +27,8 @@ import com.tencent.imsdk.v2.V2TIMConversation
|
|
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo
|
|
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo
|
|
import com.tencent.qcloud.tim.uikit.modules.chat.layout.message.MessageLayout
|
|
import com.tencent.qcloud.tim.uikit.modules.chat.layout.message.MessageLayout
|
|
import com.tencent.qcloud.tim.uikit.modules.message.MessageInfo
|
|
import com.tencent.qcloud.tim.uikit.modules.message.MessageInfo
|
|
-import java.io.FileInputStream
|
|
|
|
|
|
+import com.tencent.qcloud.tim.uikit.utils.ToastUtil
|
|
|
|
+import java.net.URL
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,10 +47,7 @@ class ChatDetailActivity : BaseXActivity<ActivityChatDetailBinding>() {
|
|
@JvmField
|
|
@JvmField
|
|
var chatName: String = ""
|
|
var chatName: String = ""
|
|
|
|
|
|
- @Autowired(required = true)
|
|
|
|
- @JvmField
|
|
|
|
- var chatSpecial: String = ""
|
|
|
|
-
|
|
|
|
|
|
+ private var svgaParser:SVGAParser? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
@@ -73,6 +65,10 @@ class ChatDetailActivity : BaseXActivity<ActivityChatDetailBinding>() {
|
|
override fun initOther() {
|
|
override fun initOther() {
|
|
ARouter.getInstance().inject(this)
|
|
ARouter.getInstance().inject(this)
|
|
|
|
|
|
|
|
+ svgaParser = SVGAParser(this)
|
|
|
|
+ if (!TextUtils.isEmpty(account)){
|
|
|
|
+ userVm.getOtherUserInfo(account,"")
|
|
|
|
+ }
|
|
val chatInfo = ChatInfo()
|
|
val chatInfo = ChatInfo()
|
|
chatInfo.type = V2TIMConversation.V2TIM_C2C
|
|
chatInfo.type = V2TIMConversation.V2TIM_C2C
|
|
chatInfo.chatName = chatName
|
|
chatInfo.chatName = chatName
|
|
@@ -97,7 +93,7 @@ class ChatDetailActivity : BaseXActivity<ActivityChatDetailBinding>() {
|
|
}
|
|
}
|
|
|
|
|
|
val messageRecyclerView = binding.chatLayout.messageLayout
|
|
val messageRecyclerView = binding.chatLayout.messageLayout
|
|
- messageRecyclerView.setOnItemClickListener(object : MessageLayout.OnItemLongClickListener{
|
|
|
|
|
|
+ messageRecyclerView?.setOnItemClickListener(object : MessageLayout.OnItemLongClickListener{
|
|
override fun onMessageLongClick(view: View?, position: Int, messageInfo: MessageInfo?) {
|
|
override fun onMessageLongClick(view: View?, position: Int, messageInfo: MessageInfo?) {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -127,30 +123,55 @@ class ChatDetailActivity : BaseXActivity<ActivityChatDetailBinding>() {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- if (UserInfo.getUserInfo() != null && !TextUtils.isEmpty(UserInfo.getUserInfo()?.chat_special)){
|
|
|
|
- UserInfo.getUserInfo()?.chat_special?.let {chatUrl ->
|
|
|
|
|
|
+ if (UserInfo.getUserInfo() != null && !TextUtils.isEmpty(UserInfo.getUserInfo()?.android_chat_special)){
|
|
|
|
+ UserInfo.getUserInfo()?.android_chat_special?.let {chatUrl ->
|
|
DianJiuUtil.loadDian9Tu(this ,chatUrl ){ drawable ->
|
|
DianJiuUtil.loadDian9Tu(this ,chatUrl ){ drawable ->
|
|
drawable?.let {
|
|
drawable?.let {
|
|
- messageRecyclerView.rightBubble = it
|
|
|
|
|
|
+ messageRecyclerView?.rightBubble = it
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- messageRecyclerView.rightBubble = ContextCompat.getDrawable(this ,R.mipmap.bg_chat_white)
|
|
|
|
|
|
+ messageRecyclerView?.rightBubble = ContextCompat.getDrawable(this ,R.mipmap.bg_chat_purple)
|
|
}
|
|
}
|
|
|
|
|
|
- if (!TextUtils.isEmpty(chatSpecial)){
|
|
|
|
- DianJiuUtil.loadDian9Tu(this ,chatSpecial ){ drawable ->
|
|
|
|
- drawable?.let {
|
|
|
|
- messageRecyclerView.leftBubble = it
|
|
|
|
|
|
+ userVm.otherUserInfoLiveData.observe(this){
|
|
|
|
+ if (TextUtils.isEmpty(it.android_chat_special)){
|
|
|
|
+ messageRecyclerView?.leftBubble = ContextCompat.getDrawable(this ,R.mipmap.bg_chat_white)
|
|
|
|
+ } else {
|
|
|
|
+ DianJiuUtil.loadDian9Tu(this ,it.android_chat_special ){ drawable ->
|
|
|
|
+ drawable?.let {
|
|
|
|
+ messageRecyclerView?.leftBubble = it
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- messageRecyclerView.leftBubble = ContextCompat.getDrawable(this ,R.mipmap.bg_chat_purple)
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(it.android_head_special)){
|
|
|
|
+ svgaParser?.decodeFromURL(URL(it.android_head_special), object :SVGAParser.ParseCompletion{
|
|
|
|
+ override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
|
+ val drawable = SVGADrawable(videoItem)
|
|
|
|
+ messageRecyclerView?.leftSvgaAvatar = drawable
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onError() {
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (UserInfo.getUserInfo() != null && !TextUtils.isEmpty(UserInfo.getUserInfo()?.android_head_special)){
|
|
|
|
+ UserInfo.getUserInfo()?.android_head_special?.let {
|
|
|
|
+ svgaParser?.decodeFromURL(URL(it), object :SVGAParser.ParseCompletion{
|
|
|
|
+ override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
|
|
+ val drawable = SVGADrawable(videoItem)
|
|
|
|
+ messageRecyclerView?.rightSvgaAvatar = drawable
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ override fun onError() {
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun initLiveData() {
|
|
override fun initLiveData() {
|
|
@@ -162,5 +183,9 @@ class ChatDetailActivity : BaseXActivity<ActivityChatDetailBinding>() {
|
|
userVm.getUserInfo()
|
|
userVm.getUserInfo()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
+ super.onDestroy()
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|