MessageModule.kt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package com.adealink.weparty.module.message
  2. import android.app.Activity
  3. import android.app.Application
  4. import androidx.lifecycle.ViewModelStoreOwner
  5. import com.adealink.frame.aab.BaseDynamicModule
  6. import com.adealink.frame.aab.constant.AABModuleNotInitError
  7. import com.adealink.frame.base.Rlt
  8. import com.adealink.frame.imkit.manager.UnReadMessageManager
  9. import com.adealink.weparty.R
  10. import com.adealink.weparty.commonui.widget.floatview.data.IFloatData
  11. import com.adealink.weparty.commonui.widget.floatview.view.BaseFloatView
  12. import com.adealink.weparty.module.message.data.CustomerInfo
  13. import com.adealink.weparty.module.message.viewmodel.IMessageViewModel
  14. import io.rong.imlib.IRongCoreCallback
  15. import io.rong.imlib.model.Conversation
  16. object MessageModule : BaseDynamicModule<IMessageService>(IMessageService::class), IMessageService {
  17. override val featureName: String
  18. get() = "message"
  19. override val moduleNameResId: Int
  20. get() = R.string.module_message
  21. override fun getMessageViewModel(owner: ViewModelStoreOwner): IMessageViewModel? {
  22. return getService().getMessageViewModel(owner)
  23. }
  24. override suspend fun batchQuerySayHiState(uidSet: Set<Long>): Rlt<Map<Long, Boolean>> {
  25. return getService().batchQuerySayHiState(uidSet)
  26. }
  27. override fun getSayHiState(uid: Long): Boolean {
  28. return getService().getSayHiState(uid)
  29. }
  30. override fun getNotificationMessageFloatView(data: IFloatData): BaseFloatView<out IFloatData>? {
  31. return getService().getNotificationMessageFloatView(data)
  32. }
  33. override fun addUnReadMessageCountChangedObserver(
  34. observer: UnReadMessageManager.IUnReadMessageObserver,
  35. conversationTypes: Array<Conversation.ConversationType>
  36. ) {
  37. getService().addUnReadMessageCountChangedObserver(observer, conversationTypes)
  38. }
  39. override fun addUnReadMessageCountChangedObserver(
  40. observer: UnReadMessageManager.IUnReadMessageObserver,
  41. conversationType: Conversation.ConversationType,
  42. targetId: String
  43. ) {
  44. getService().addUnReadMessageCountChangedObserver(observer, conversationType, targetId)
  45. }
  46. override fun logout() {
  47. getService().logout()
  48. }
  49. override fun getUnreadConversationList(callback: IRongCoreCallback.ResultCallback<List<Conversation>?>, vararg conversationTypes: Conversation.ConversationType) {
  50. getService().getUnreadConversationList(callback, *conversationTypes)
  51. }
  52. override suspend fun getCustomerList(cache: Boolean): List<CustomerInfo>? {
  53. return getService().getCustomerList(cache)
  54. }
  55. override suspend fun checkIsCustomerService(targetId: Long, cache: Boolean): Boolean {
  56. return getService().checkIsCustomerService(targetId, cache)
  57. }
  58. override fun appOnCreateMainTask(application: Application) {
  59. return getService().appOnCreateMainTask(application)
  60. }
  61. override fun appOnCreateSubTask(application: Application) {
  62. return getService().appOnCreateSubTask(application)
  63. }
  64. override fun activityOnCreateMainTask() {
  65. return getService().activityOnCreateMainTask()
  66. }
  67. override fun activityOnCreateSubTask() {
  68. return getService().activityOnCreateSubTask()
  69. }
  70. override fun emptyService(): IMessageService {
  71. return object : IMessageService {
  72. override fun getMessageViewModel(owner: ViewModelStoreOwner): IMessageViewModel? {
  73. return null
  74. }
  75. override suspend fun batchQuerySayHiState(uidSet: Set<Long>): Rlt<Map<Long, Boolean>> {
  76. return Rlt.Failed(AABModuleNotInitError())
  77. }
  78. override fun getSayHiState(uid: Long): Boolean {
  79. return false
  80. }
  81. override fun getNotificationMessageFloatView(data: IFloatData): BaseFloatView<out IFloatData>? {
  82. return null
  83. }
  84. override fun addUnReadMessageCountChangedObserver(
  85. observer: UnReadMessageManager.IUnReadMessageObserver,
  86. conversationTypes: Array<Conversation.ConversationType>
  87. ) {
  88. }
  89. override fun addUnReadMessageCountChangedObserver(
  90. observer: UnReadMessageManager.IUnReadMessageObserver,
  91. conversationType: Conversation.ConversationType,
  92. targetId: String
  93. ) {
  94. }
  95. override fun logout() {
  96. }
  97. override fun getUnreadConversationList(callback: IRongCoreCallback.ResultCallback<List<Conversation>?>, vararg conversationTypes: Conversation.ConversationType) {
  98. }
  99. override suspend fun getCustomerList(cache: Boolean): List<CustomerInfo>? {
  100. return null
  101. }
  102. override suspend fun checkIsCustomerService(targetId: Long, cache: Boolean): Boolean {
  103. return false
  104. }
  105. override fun getService(): IMessageService? {
  106. return null
  107. }
  108. override fun appOnCreateMainTask(application: Application) {
  109. }
  110. override fun appOnCreateSubTask(application: Application) {
  111. }
  112. override fun activityOnCreateMainTask() {
  113. }
  114. override fun activityOnCreateSubTask() {
  115. }
  116. }
  117. }
  118. }