Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
b88f7457
Commit
b88f7457
authored
Sep 09, 2020
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reactor:初始化README文件,将客服小壹id 14 提取到常量中,方便后续修改
parent
9632959d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
347 additions
and
212 deletions
+347
-212
README.md
README.md
+28
-0
P2PCustomActionHandlerImpl.java
m-im/src/main/java/com/yidianling/im/bridge/P2PCustomActionHandlerImpl.java
+2
-2
ImConstants.kt
m-im/src/main/java/com/yidianling/im/config/constants/ImConstants.kt
+2
-1
IMChatUtil.kt
m-im/src/main/java/com/yidianling/im/helper/IMChatUtil.kt
+310
-206
IMServiceImpl.kt
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
+2
-1
NewMultiMessageFragment.kt
m-im/src/main/java/com/yidianling/im/ui/page/NewMultiMessageFragment.kt
+3
-2
No files found.
README.md
0 → 100644
View file @
b88f7457
# 壹点灵 v4.1.55
# AS 规范
尽量使用同一版本的 IDE 进行开发
编码格式统一为 UTF-8
编辑完 .kt .java、.xml 等文件后一定要 格式化,格式化,格式化(使用 AS 默认模板即可)
代码格式化:Command + Option + L | Control + Alt + L
删除多余的 import,减少警告出现,可利用 AS 的 Optimize Imports(Settings -> Keymap -> Optimize Imports)
无用import清理:Control + Option + O | Control + Alt + O
# commit 风格
使用中文表达,尽量控制在 20 个字以内(如果你发觉 20 个字描述不了,那很可能是因为这一次 commit 不够纯粹,可以考虑将之分成两部分内容或更多内容分次提交)
保持 commit 是纯粹的、详细的 (有利于我们发现问题时进行细粒化到具体内容 revert commit,而不是遇到问题需要 revert 结果把一些好的、没问题的内容也捆绑 revert 掉了)
格式:(一般情况下使用下面 7 种标识已经足够了)
feat:新功能(feature)
fix:修补bug
docs:文档(documentation)
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试
chore:构建过程或辅助工具的变动
# yidianling
# yidianling
m-im/src/main/java/com/yidianling/im/bridge/P2PCustomActionHandlerImpl.java
View file @
b88f7457
...
@@ -274,7 +274,7 @@ public class P2PCustomActionHandlerImpl implements IP2PCustomActionHandler {
...
@@ -274,7 +274,7 @@ public class P2PCustomActionHandlerImpl implements IP2PCustomActionHandler {
@Override
@Override
public
boolean
isBindPhone
(
final
Activity
activity
,
String
toUid
)
{
public
boolean
isBindPhone
(
final
Activity
activity
,
String
toUid
)
{
//小壹特殊处理,没有绑定也可以和小壹聊天
//小壹特殊处理,没有绑定也可以和小壹聊天
if
(
toUid
.
equals
(
"14"
))
{
if
(
toUid
.
equals
(
ImConstants
.
KEFUXIAOYI
))
{
return
true
;
return
true
;
}
}
...
@@ -585,7 +585,7 @@ public class P2PCustomActionHandlerImpl implements IP2PCustomActionHandler {
...
@@ -585,7 +585,7 @@ public class P2PCustomActionHandlerImpl implements IP2PCustomActionHandler {
if
(
mActivity
==
null
||
mActivity
.
isFinishing
())
return
;
if
(
mActivity
==
null
||
mActivity
.
isFinishing
())
return
;
list
.
clear
();
list
.
clear
();
if
(
"14"
.
equals
(
toChatUsername
)
||
"4108805"
.
equals
(
toChatUsername
))
{
if
(
ImConstants
.
KEFUXIAOYI
.
equals
(
toChatUsername
)
||
"4108805"
.
equals
(
toChatUsername
))
{
list
.
add
(
"历史聊天记录"
);
list
.
add
(
"历史聊天记录"
);
// list.add("返回首页");
// list.add("返回首页");
list
.
add
(
"客服热线"
);
list
.
add
(
"客服热线"
);
...
...
m-im/src/main/java/com/yidianling/im/config/constants/ImConstants.kt
View file @
b88f7457
...
@@ -42,7 +42,8 @@ class ImConstants {
...
@@ -42,7 +42,8 @@ class ImConstants {
//连接倾听未绑定手机提示
//连接倾听未绑定手机提示
const
val
TEL_BINDPHONE
=
"电话连接需要绑定手机哦~"
const
val
TEL_BINDPHONE
=
"电话连接需要绑定手机哦~"
const
val
KEFUXIAOYI
=
"14"
}
}
...
...
m-im/src/main/java/com/yidianling/im/helper/IMChatUtil.kt
View file @
b88f7457
...
@@ -2,6 +2,7 @@ package com.yidianling.im.helper
...
@@ -2,6 +2,7 @@ package com.yidianling.im.helper
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
android.support.v4.content.ContextCompat
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.app.AppCompatActivity
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.View
import
android.view.View
...
@@ -64,7 +65,13 @@ object IMChatUtil {
...
@@ -64,7 +65,13 @@ object IMChatUtil {
* 客服专用
* 客服专用
*/
*/
fun
startKefuChat
(
context
:
AppCompatActivity
?)
{
fun
startKefuChat
(
context
:
AppCompatActivity
?)
{
SessionHelper
.
startP2PSession
(
context
,
-
1
,
"14"
,
null
,
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"14"
))
SessionHelper
.
startP2PSession
(
context
,
-
1
,
ImConstants
.
KEFUXIAOYI
,
null
,
P2PCustomActionHandlerImpl
(
ImConstants
.
KEFUXIAOYI
,
"客服小壹"
,
ImConstants
.
KEFUXIAOYI
)
)
}
}
/**
/**
...
@@ -74,11 +81,12 @@ object IMChatUtil {
...
@@ -74,11 +81,12 @@ object IMChatUtil {
* @param chatItemBean
* @param chatItemBean
*/
*/
fun
startChat
(
context
:
AppCompatActivity
?,
chatItemBean
:
ChatItemBean
)
{
fun
startChat
(
context
:
AppCompatActivity
?,
chatItemBean
:
ChatItemBean
)
{
SessionHelper
.
startP2PSession
(
context
,
SessionHelper
.
startP2PSession
(
chatItemBean
.
utype
,
context
,
chatItemBean
.
toUid
.
toString
(),
chatItemBean
.
utype
,
null
,
chatItemBean
.
toUid
.
toString
(),
P2PCustomActionHandlerImpl
(
chatItemBean
)
null
,
P2PCustomActionHandlerImpl
(
chatItemBean
)
)
)
}
}
...
@@ -101,63 +109,63 @@ object IMChatUtil {
...
@@ -101,63 +109,63 @@ object IMChatUtil {
loadingDialog
?.
show
(
context
.
supportFragmentManager
,
null
)
loadingDialog
?.
show
(
context
.
supportFragmentManager
,
null
)
}
}
getImJavaApi
().
getUserType
(
toUid
)
getImJavaApi
().
getUserType
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
res
:
BaseResponse
<
UserTypeBean
>
->
.
subscribe
({
res
:
BaseResponse
<
UserTypeBean
>
->
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
data
!!
.
chatEvent
)
{
//和助理私聊需要打开常用语弹窗
if
(
res
.
data
!!
.
chatEvent
)
{
//和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper
.
setStatusCache
(
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
"chatEvent"
,
res
.
data
!!
.
chatEvent
res
.
data
!!
.
chatEvent
)
)
}
}
if
(
res
.
data
!!
.
collectEvent
)
{
//和助理私聊需要打开信息采集弹窗
if
(
res
.
data
!!
.
collectEvent
)
{
//和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper
.
setStatusCache
(
ChatStatusCacheHelper
.
setStatusCache
(
"collectEvent"
,
"collectEvent"
,
res
.
data
!!
.
collectEvent
res
.
data
!!
.
collectEvent
)
)
}
}
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
//专家
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
//专家
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
getImJavaApi
().
getChatUid
(
toUid
)
getImJavaApi
().
getChatUid
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
resp
:
BaseAPIResponse
<
DoctorAssistantRespDtoBean
>
->
.
subscribe
({
resp
:
BaseAPIResponse
<
DoctorAssistantRespDtoBean
>
->
val
bean
=
resp
.
data
val
bean
=
resp
.
data
val
toUid
=
bean
.
chatUid
val
toUid
=
bean
.
chatUid
prepareChatData
(
context
,
toUid
,
object
:
prepareChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
ChatDataRequestListener
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
}
})
})
{
t
:
Throwable
?
->
handleError
(
context
,
t
!!
)
}
}
}
else
{
})
prepareAssistantChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
})
{
t
:
Throwable
?
->
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
handleError
(
context
,
t
!!
)
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
}
}
})
}
}
else
{
}
else
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
prepareAssistantChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
loadingDialog
?.
dismissAllowingStateLoss
()
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
}
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
ToastUtil
.
toastShort
(
res
.
msg
)
}
})
}
}
}
,
{
throwable
:
Throwable
?
->
}
else
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
loadingDialog
?.
dismissAllowingStateLoss
()
}
}
handleError
(
context
,
throwable
!!
)
ToastUtil
.
toastShort
(
res
.
msg
)
}
}
)
},
{
throwable
:
Throwable
?
->
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
!!
)
}
)
}
}
fun
startChatCloseReplaceChat
(
context
:
AppCompatActivity
,
toUid
:
String
){
fun
startChatCloseReplaceChat
(
context
:
AppCompatActivity
,
toUid
:
String
)
{
if
(!
isLogin
(
context
,
true
))
{
if
(!
isLogin
(
context
,
true
))
{
return
return
}
}
...
@@ -168,7 +176,7 @@ object IMChatUtil {
...
@@ -168,7 +176,7 @@ object IMChatUtil {
loadingDialog
?.
show
(
context
.
supportFragmentManager
,
null
)
loadingDialog
?.
show
(
context
.
supportFragmentManager
,
null
)
}
}
prepareChatData
(
context
,
toUid
,
object
:
prepareChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
ChatDataRequestListener
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
startChatSession
(
toUid
,
expertInfo
,
0
,
context
)
startChatSession
(
toUid
,
expertInfo
,
0
,
context
)
}
}
...
@@ -178,200 +186,281 @@ object IMChatUtil {
...
@@ -178,200 +186,281 @@ object IMChatUtil {
/**
/**
* 开启聊天会话
* 开启聊天会话
*/
*/
private
fun
startChatSession
(
toUid
:
String
,
expertInfo
:
IMExpertBuild
,
isFromQingShu
:
Int
,
context
:
AppCompatActivity
)
{
private
fun
startChatSession
(
toUid
:
String
,
expertInfo
:
IMExpertBuild
,
isFromQingShu
:
Int
,
context
:
AppCompatActivity
)
{
val
p2PCustomActionHandlerImpl
=
P2PCustomActionHandlerImpl
(
toUid
,
expertInfo
)
val
p2PCustomActionHandlerImpl
=
P2PCustomActionHandlerImpl
(
toUid
,
expertInfo
)
p2PCustomActionHandlerImpl
.
isFromQingShu
=
isFromQingShu
p2PCustomActionHandlerImpl
.
isFromQingShu
=
isFromQingShu
SessionHelper
.
startP2PSession
(
context
,
expertInfo
.
shareData
.
user_type
,
toUid
,
null
,
p2PCustomActionHandlerImpl
)
SessionHelper
.
startP2PSession
(
context
,
expertInfo
.
shareData
.
user_type
,
toUid
,
null
,
p2PCustomActionHandlerImpl
)
}
}
//====================准备私聊数据====================
//====================准备私聊数据====================
/**
/**
* 初始化聊天数据
* 初始化聊天数据
*/
*/
fun
prepareChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
fun
prepareChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
if
(!
isLogin
(
context
,
true
))
{
if
(!
isLogin
(
context
,
true
))
{
return
return
}
}
val
dis
=
getImJavaApi
().
getUserType
(
toUid
)
val
dis
=
getImJavaApi
().
getUserType
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
res
:
BaseResponse
<
UserTypeBean
>
->
.
subscribe
({
res
:
BaseResponse
<
UserTypeBean
>
->
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
data
!!
.
chatEvent
)
{
//和助理私聊需要打开常用语弹窗
if
(
res
.
data
!!
.
chatEvent
)
{
//和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
res
.
data
!!
.
chatEvent
)
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
res
.
data
!!
.
chatEvent
)
}
}
if
(
res
.
data
!!
.
collectEvent
)
{
//和助理私聊需要打开信息采集弹窗
if
(
res
.
data
!!
.
collectEvent
)
{
//和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"collectEvent"
,
res
.
data
!!
.
collectEvent
)
ChatStatusCacheHelper
.
setStatusCache
(
}
"collectEvent"
,
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
res
.
data
!!
.
collectEvent
//接口返回值是专家,java接口
)
prepareExpertChatData
(
context
,
toUid
,
listener
)
}
else
{
//非专家 php接口
prepareAssistantChatData
(
context
,
toUid
,
listener
)
}
}
else
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
ToastUtil
.
toastShort
(
res
.
msg
)
}
}
},
{
throwable
:
Throwable
?
->
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
//接口返回值是专家,java接口
prepareExpertChatData
(
context
,
toUid
,
listener
)
}
else
{
//非专家 php接口
prepareAssistantChatData
(
context
,
toUid
,
listener
)
}
}
else
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
loadingDialog
?.
dismissAllowingStateLoss
()
}
}
handleError
(
context
,
throwable
!!
)
ToastUtil
.
toastShort
(
res
.
msg
)
}
}
)
},
{
throwable
:
Throwable
?
->
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
!!
)
}
)
}
}
/**
/**
* 专家私聊数据请求
* 专家私聊数据请求
*/
*/
fun
prepareExpertChatData
(
context
:
AppCompatActivity
,
toUid
:
String
?,
listener
:
ChatDataRequestListener
)
{
fun
prepareExpertChatData
(
context
:
AppCompatActivity
,
toUid
:
String
?,
listener
:
ChatDataRequestListener
)
{
val
disposable
=
getImJavaApi
().
getPersonalChat
(
toUid
!!
)
val
disposable
=
getImJavaApi
().
getPersonalChat
(
toUid
!!
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
resp
:
BaseResponse
<
IMExpertBuild
>
->
if
(
null
!=
loadingDialog
&&
loadingDialog
?.
isVisible
!!
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
if
(
resp
.
code
==
200
)
{
val
expert
=
resp
.
data
UserInfoCache
.
getInstance
().
saveYDLUser
(
expert
.
shareData
.
toUid
,
expert
.
shareData
.
doctorName
,
expert
.
shareData
.
cover
)
listener
.
onSuccess
(
expert
)
}
else
{
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
)
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
context
.
startActivity
(
loginWayIntent
(
context
))
ToastUtil
.
toastShort
(
resp
.
msg
)
}
else
if
(
resp
.
code
==
ImConstants
.
SILENCED_CODE
)
{
//禁言
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
}
else
{
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
}
)
{
throwable
:
Throwable
->
if
(
null
!=
loadingDialog
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
)
if
(
throwable
is
HttpException
)
{
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
}
}
}
/**
* 助理私聊数据请求
*/
fun
prepareAssistantChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
val
cmd
=
GetExpert
(
toUid
.
toInt
(),
0
)
val
disposable
=
getImRetrofitApi
().
getExpert
(
NetworkParamsUtils
.
getMaps
(
cmd
))
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
resp
:
BaseResponse
<
IMExpertBuild
>
->
.
subscribe
({
resp
:
BaseResponse
<
IMExpertBuild
>
->
if
(
null
!=
loadingDialog
&&
loadingDialog
?.
isVisible
!!
)
{
if
(
null
!=
loadingDialog
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
loadingDialog
?.
dismissAllowingStateLoss
()
}
}
if
(
resp
.
code
==
200
)
{
if
(
resp
.
code
==
0
)
{
val
expert
=
resp
.
data
val
expert
=
resp
.
data
UserInfoCache
.
getInstance
().
saveYDLUser
(
expert
.
shareData
.
toUid
,
expert
.
shareData
.
doctorName
,
expert
.
shareData
.
cover
)
UserInfoCache
.
getInstance
().
saveYDLUser
(
listener
.
onSuccess
(
expert
)
expert
.
shareData
.
toUid
,
}
else
{
expert
.
shareData
.
doctorName
,
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
)
expert
.
shareData
.
cover
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
)
context
.
startActivity
(
loginWayIntent
(
context
))
listener
?.
onSuccess
(
expert
)
ToastUtil
.
toastShort
(
resp
.
msg
)
}
else
{
}
else
if
(
resp
.
code
==
ImConstants
.
SILENCED_CODE
)
{
//禁言
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
)
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
}
else
{
context
.
startActivity
(
loginWayIntent
(
context
))
ToastUtil
.
toastShort
(
resp
.
msg
)
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
else
if
(
resp
.
code
==
ImConstants
.
SILENCED_CODE
)
{
//禁言
}
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
}
else
{
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
}
}
)
{
throwable
:
Throwable
->
)
{
throwable
:
Throwable
->
if
(
null
!=
loadingDialog
&&
loadingDialog
!!
.
isVisible
)
{
if
(
null
!=
loadingDialog
&&
loadingDialog
?.
isVisible
!!
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
loadingDialog
?.
dismissAllowingStateLoss
()
}
}
handleError
(
context
,
throwable
)
handleError
(
context
,
throwable
)
if
(
throwable
is
HttpException
)
{
if
(
throwable
is
HttpException
)
{
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
}
}
}
}
}
}
/**
* 助理私聊数据请求
*/
fun
prepareAssistantChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
val
cmd
=
GetExpert
(
toUid
.
toInt
(),
0
)
val
disposable
=
getImRetrofitApi
().
getExpert
(
NetworkParamsUtils
.
getMaps
(
cmd
))
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
resp
:
BaseResponse
<
IMExpertBuild
>
->
if
(
null
!=
loadingDialog
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
if
(
resp
.
code
==
0
)
{
val
expert
=
resp
.
data
UserInfoCache
.
getInstance
().
saveYDLUser
(
expert
.
shareData
.
toUid
,
expert
.
shareData
.
doctorName
,
expert
.
shareData
.
cover
)
listener
?.
onSuccess
(
expert
)
}
else
{
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
)
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
context
.
startActivity
(
loginWayIntent
(
context
))
ToastUtil
.
toastShort
(
resp
.
msg
)
}
else
if
(
resp
.
code
==
ImConstants
.
SILENCED_CODE
)
{
//禁言
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
}
else
{
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
}
)
{
throwable
:
Throwable
->
if
(
null
!=
loadingDialog
&&
loadingDialog
?.
isVisible
!!
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
)
if
(
throwable
is
HttpException
)
{
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
}
}
}
//====================私聊页面 初始化操作====================
//====================私聊页面 初始化操作====================
/**
/**
* 初始化在线状态接口
* 初始化在线状态接口
*
* 只有专家显示在线、离线标识,其他用户Type隐藏在线、离线标识
*/
*/
fun
initChatOnlineState
(
tb
:
TitleBarBottom
,
context
:
Context
,
toUid
:
String
,
messageFragment
:
YDLMessageFragment
)
{
fun
initChatOnlineState
(
tb
:
TitleBarBottom
,
context
:
Context
,
toUid
:
String
,
messageFragment
:
YDLMessageFragment
)
{
val
actionHandler
=
ActionHandlerStorage
.
getL
(
toUid
)
val
actionHandler
=
ActionHandlerStorage
.
getL
(
toUid
)
//获取私聊对方在线状态
//获取私聊对方在线状态
if
(
null
!=
actionHandler
)
{
if
(
null
!=
actionHandler
)
{
val
docInfo
=
actionHandler
.
info
val
docInfo
=
actionHandler
.
info
if
(
null
!=
docInfo
&&
(
"14"
==
docInfo
.
toUid
||
"4108805"
==
docInfo
.
toUid
))
{
//小壹客服 不显示是否在线
docInfo
.
doctorBriefInfoFeedbackRate
if
(
null
!=
docInfo
&&
(
ImConstants
.
KEFUXIAOYI
==
docInfo
.
toUid
||
"4108805"
==
docInfo
.
toUid
))
{
//小壹客服 不显示是否在线
tb
.
setmMinTitleVisiable
(
View
.
GONE
)
tb
.
setmMinTitleVisiable
(
View
.
GONE
)
}
else
{
}
else
{
//对方是用户,自己是助理
//对方是用户,自己是助理
if
(
actionHandler
.
userType
==
1
&&
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
user_type
==
3
)
{
if
(
actionHandler
.
userType
==
1
&&
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
)
.
getUserInfo
()
?.
user_type
==
3
)
{
tb
.
setTitleTextRightIcon
(
R
.
drawable
.
user_info_icon
)
{
tb
.
setTitleTextRightIcon
(
R
.
drawable
.
user_info_icon
)
{
messageFragment
.
showUserInfoDialog
()
messageFragment
.
showUserInfoDialog
()
}
}
}
}
if
(
actionHandler
.
userType
==
2
)
{
// 专家
if
(
actionHandler
.
userType
==
2
)
{
// 专家
tb
.
setmMinTitleVisiable
(
View
.
VISIBLE
)
// 调取接口获取专家状态
// 调取接口获取专家状态
val
dis
=
instance
val
dis
=
instance
.
getDoctorChatStatus
(
actionHandler
.
info
.
toUid
.
toLong
())
.
getDoctorChatStatus
(
actionHandler
.
info
.
toUid
.
toLong
())
.
compose
(
applySchedulers
())
.
compose
(
applySchedulers
())
.
subscribe
(
.
subscribe
(
{
chatStatusBean
:
BaseAPIResponse
<
ChatStatusBean
>
->
{
chatStatusBean
:
BaseAPIResponse
<
ChatStatusBean
>
->
if
(
actionHandler
!=
null
)
{
if
(
actionHandler
!=
null
)
{
val
status
=
chatStatusBean
.
data
.
status
val
status
=
chatStatusBean
.
data
.
status
actionHandler
.
setDoctorStatus
(
status
)
actionHandler
.
setDoctorStatus
(
status
)
actionHandler
.
setDoctorBusyNum
(
chatStatusBean
.
data
.
busyTotal
)
actionHandler
.
setDoctorBusyNum
(
chatStatusBean
.
data
.
busyTotal
)
//1.在线,2.离线,3.忙碌 4咨询中, 5倾述中 6咨询前准备
//1.在线,2.离线,3.忙碌 4咨询中, 5倾述中 6咨询前准备
if
(
status
==
2
)
{
//离线
if
(
status
==
2
)
{
//离线
tb
.
setMinTitleText
(
"离线"
)
tb
.
setMinTitleText
(
"离线"
)
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
tb
.
setMinTitleColor
(
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_off_line
))
ContextCompat
.
getColor
(
}
else
if
(
status
==
4
||
status
==
5
)
{
//服务中
context
,
tb
.
setMinTitleText
(
"服务中"
)
R
.
color
.
platform_color_666666
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
)
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_online_server
))
)
}
else
{
//在线 1,3,6..
tb
.
setMinTitleDrawable
(
tb
.
setMinTitleText
(
"在线"
)
ContextCompat
.
getDrawable
(
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
context
,
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_online
))
R
.
drawable
.
im_background_chat_top_status_off_line
}
)
initSystemMessage
(
chatStatusBean
.
data
.
promptRule
,
status
,
toUid
,
actionHandler
)
)
}
}
else
if
(
status
==
4
||
status
==
5
)
{
//服务中
tb
.
setMinTitleText
(
"服务中"
)
tb
.
setMinTitleColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
platform_color_666666
)
)
tb
.
setMinTitleDrawable
(
ContextCompat
.
getDrawable
(
context
,
R
.
drawable
.
im_background_chat_top_status_online_server
)
)
}
else
{
//在线 1,3,6..
tb
.
setMinTitleText
(
"在线"
)
tb
.
setMinTitleColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
platform_color_666666
)
)
tb
.
setMinTitleDrawable
(
ContextCompat
.
getDrawable
(
context
,
R
.
drawable
.
im_background_chat_top_status_online
)
)
}
}
)
{
throwable
:
Throwable
->
initSystemMessage
(
LogUtil
.
i
(
"getDoctorChatStatus throwable:$throwable"
)
chatStatusBean
.
data
.
promptRule
,
status
,
toUid
,
actionHandler
)
}
}
}
)
{
throwable
:
Throwable
->
LogUtil
.
i
(
"getDoctorChatStatus throwable:$throwable"
)
}
}
else
if
(
actionHandler
.
userType
==
3
)
{
// 助理
}
else
if
(
actionHandler
.
userType
==
3
)
{
// 助理
tb
.
setmMinTitleVisiable
(
View
.
GONE
)
// 调取接口获取助理状态
// 调取接口获取助理状态
instance
.
getAssistantChatStatus
(
instance
.
getAssistantChatStatus
(
actionHandler
.
info
.
toUid
.
toLong
()
actionHandler
.
info
.
toUid
.
toLong
()
)
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
res
:
BaseAPIResponse
<
Int
>
->
.
subscribe
({
res
:
BaseAPIResponse
<
Int
>
->
if
(
actionHandler
!=
null
)
{
if
(
actionHandler
!=
null
)
{
if
(
res
.
data
==
1
)
{
//在线
if
(
res
.
data
==
1
)
{
//在线
tb
.
setMinTitleText
(
"在线"
)
/*tb.setMinTitleText("在线")
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
tb.setMinTitleColor(context.resources.getColor(R.color.platform_color_666666))
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_online
))
tb.setMinTitleDrawable(context.resources.getDrawable(R.drawable.im_background_chat_top_status_online))*/
}
else
{
//离线
}
else
{
//离线
tb
.
setMinTitleText
(
"离线"
)
/* tb.setMinTitleText("离线")
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
tb.setMinTitleColor(context.resources.getColor(R.color.platform_color_666666))
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_off_line
))
tb.setMinTitleDrawable(context.resources.getDrawable(R.drawable.im_background_chat_top_status_off_line))*/
}
}
}
}
}
)
{
throwable
:
Throwable
?
->
}
}
)
{
throwable
:
Throwable
?
->
}
}
else
{
}
else
{
tb
.
setmMinTitleVisiable
(
View
.
GONE
)
tb
.
setmMinTitleVisiable
(
View
.
GONE
)
}
}
...
@@ -381,7 +470,12 @@ object IMChatUtil {
...
@@ -381,7 +470,12 @@ object IMChatUtil {
// promptRule 判断是否推荐专家 4,5直接不走文本提示和推荐逻辑,1,3不走推荐逻辑
// promptRule 判断是否推荐专家 4,5直接不走文本提示和推荐逻辑,1,3不走推荐逻辑
//初始化 根据专家在线状态来发送提示消息或者推荐消息
//初始化 根据专家在线状态来发送提示消息或者推荐消息
private
fun
initSystemMessage
(
promptRule
:
Int
,
status
:
Int
,
toUid
:
String
,
actionHandler
:
IP2PCustomActionHandler
)
{
private
fun
initSystemMessage
(
promptRule
:
Int
,
status
:
Int
,
toUid
:
String
,
actionHandler
:
IP2PCustomActionHandler
)
{
if
(!(
promptRule
==
4
||
promptRule
==
5
))
{
if
(!(
promptRule
==
4
||
promptRule
==
5
))
{
val
showExpertList
=
!(
promptRule
==
1
||
promptRule
==
3
)
val
showExpertList
=
!(
promptRule
==
1
||
promptRule
==
3
)
if
(
actionHandler
.
userType
==
2
&&
status
==
2
)
{
//当该专家离线时
if
(
actionHandler
.
userType
==
2
&&
status
==
2
)
{
//当该专家离线时
...
@@ -396,29 +490,38 @@ object IMChatUtil {
...
@@ -396,29 +490,38 @@ object IMChatUtil {
* 发送推荐专家列表
* 发送推荐专家列表
*/
*/
@SuppressLint
(
"CheckResult"
)
@SuppressLint
(
"CheckResult"
)
fun
sendRecommendExpertListMessage
(
type
:
Int
,
showExpertList
:
Boolean
,
toUid
:
String
,
actionHandler
:
IP2PCustomActionHandler
)
{
// 调取接口获取推荐专家列表
fun
sendRecommendExpertListMessage
(
instance
.
getRecommendExpertList
(
actionHandler
.
info
.
toUid
.
toLong
(),
URLEncoder
.
encode
(
actionHandler
.
info
.
tag1
),
3
)
type
:
Int
,
.
subscribeOn
(
Schedulers
.
io
())
showExpertList
:
Boolean
,
.
observeOn
(
AndroidSchedulers
.
mainThread
())
toUid
:
String
,
.
subscribe
({
res
:
BaseAPIResponse
<
ArrayList
<
RecommendExpertBean
>>
->
actionHandler
:
IP2PCustomActionHandler
//发送推荐专家列表消息
)
{
// 调取接口获取推荐专家列表
actionHandler
.
sendRecommendExpertListMessage
(
toUid
,
res
.
data
,
type
,
showExpertList
)
instance
.
getRecommendExpertList
(
},
{
throwable
:
Throwable
->
ToastUtil
.
toastShort
(
throwable
.
toString
())
})
actionHandler
.
info
.
toUid
.
toLong
(),
URLEncoder
.
encode
(
actionHandler
.
info
.
tag1
),
3
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
res
:
BaseAPIResponse
<
ArrayList
<
RecommendExpertBean
>>
->
//发送推荐专家列表消息
actionHandler
.
sendRecommendExpertListMessage
(
toUid
,
res
.
data
,
type
,
showExpertList
)
},
{
throwable
:
Throwable
->
ToastUtil
.
toastShort
(
throwable
.
toString
())
})
}
}
//====================展示提示====================
//====================展示提示====================
fun
showSilencedDialog
(
context
:
Context
,
tips
:
String
?,
url
:
String
?)
{
fun
showSilencedDialog
(
context
:
Context
,
tips
:
String
?,
url
:
String
?)
{
CommonDialog
.
create
(
context
)
CommonDialog
.
create
(
context
)
.
setMessage
(
tips
)
.
setMessage
(
tips
)
.
setCancelAble
(
false
)
.
setCancelAble
(
false
)
.
setLeftOnclick
(
.
setLeftOnclick
(
context
.
getString
(
R
.
string
.
im_details
)
context
.
getString
(
R
.
string
.
im_details
)
)
{
)
{
val
realUrl
=
if
(
TextUtils
.
isEmpty
(
url
))
ImConstants
.
HELP_URL
else
url
!!
val
realUrl
=
if
(
TextUtils
.
isEmpty
(
url
))
ImConstants
.
HELP_URL
else
url
!!
val
params
=
H5Params
(
realUrl
,
""
)
val
params
=
H5Params
(
realUrl
,
""
)
NewH5Activity
.
start
(
context
,
params
)
NewH5Activity
.
start
(
context
,
params
)
}
}
.
setRightClick
(
context
.
getString
(
R
.
string
.
im_approval
),
null
)
.
setRightClick
(
context
.
getString
(
R
.
string
.
im_approval
),
null
)
.
show
()
.
show
()
}
}
}
}
\ No newline at end of file
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
View file @
b88f7457
...
@@ -31,6 +31,7 @@ import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
...
@@ -31,6 +31,7 @@ import com.yidianling.im.api.bean.IMSendCustomNotificationResultCallBack
import
com.yidianling.im.api.service.IImService
import
com.yidianling.im.api.service.IImService
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import
com.yidianling.im.config.NimApplication
import
com.yidianling.im.config.NimApplication
import
com.yidianling.im.config.constants.ImConstants
import
com.yidianling.im.helper.IMChatUtil
import
com.yidianling.im.helper.IMChatUtil
import
com.yidianling.im.helper.LogoutHelper
import
com.yidianling.im.helper.LogoutHelper
import
com.yidianling.im.helper.ImObserversHelper
import
com.yidianling.im.helper.ImObserversHelper
...
@@ -73,7 +74,7 @@ class IMServiceImpl : IImService {
...
@@ -73,7 +74,7 @@ class IMServiceImpl : IImService {
context
.
startActivity
(
ImIn
.
loginWayIntent
(
context
))
context
.
startActivity
(
ImIn
.
loginWayIntent
(
context
))
return
return
}
}
SessionHelper
.
startP2PSession
(
context
,
-
1
,
"14"
,
null
,
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"https://static.ydlcdn.com/mobile/images/avatar_girl_app.png"
))
SessionHelper
.
startP2PSession
(
context
,
-
1
,
ImConstants
.
KEFUXIAOYI
,
null
,
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"https://static.ydlcdn.com/mobile/images/avatar_girl_app.png"
))
}
}
override
fun
imLogin
(
info
:
IMLoginInfo
)
{
override
fun
imLogin
(
info
:
IMLoginInfo
)
{
...
...
m-im/src/main/java/com/yidianling/im/ui/page/NewMultiMessageFragment.kt
View file @
b88f7457
...
@@ -20,6 +20,7 @@ import com.yidianling.im.R
...
@@ -20,6 +20,7 @@ import com.yidianling.im.R
import
com.yidianling.im.api.event.ImLogoutEvent
import
com.yidianling.im.api.event.ImLogoutEvent
import
com.yidianling.im.api.event.UpdateBottomBarUnreadNumEvent
import
com.yidianling.im.api.event.UpdateBottomBarUnreadNumEvent
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import
com.yidianling.im.config.constants.ImConstants
import
com.yidianling.im.event.MessageListRefreshEvent
import
com.yidianling.im.event.MessageListRefreshEvent
import
com.yidianling.im.event.ReQureyUnreadNum
import
com.yidianling.im.event.ReQureyUnreadNum
import
com.yidianling.im.event.UpdateTabUnreadNumEvent
import
com.yidianling.im.event.UpdateTabUnreadNumEvent
...
@@ -295,8 +296,8 @@ class NewMultiMessageFragment : BaseFragment() {
...
@@ -295,8 +296,8 @@ class NewMultiMessageFragment : BaseFragment() {
private
fun
initKefu
()
{
private
fun
initKefu
()
{
ll_kefu
.
setOnClickListener
{
ll_kefu
.
setOnClickListener
{
if
(
ImIn
.
isLogin
())
{
if
(
ImIn
.
isLogin
())
{
SessionHelper
.
startP2PSession
(
context
,
-
1
,
"14"
,
null
,
SessionHelper
.
startP2PSession
(
context
,
-
1
,
ImConstants
.
KEFUXIAOYI
,
null
,
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"14"
))
P2PCustomActionHandlerImpl
(
ImConstants
.
KEFUXIAOYI
,
"客服小壹"
,
ImConstants
.
KEFUXIAOYI
))
}
else
{
}
else
{
ToastUtil
.
toastShort
(
"请登录后再试"
)
ToastUtil
.
toastShort
(
"请登录后再试"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment