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
4733f993
Commit
4733f993
authored
Mar 30, 2020
by
konghaorui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测评后置接口补充
parent
11c8adb3
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
182 additions
and
447 deletions
+182
-447
DemoGlobalConfig.java
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
+2
-2
IMChatUtil.kt
m-im/src/main/java/com/yidianling/im/helper/IMChatUtil.kt
+163
-157
IMUtil.java
m-im/src/main/java/com/yidianling/im/helper/IMUtil.java
+0
-276
IMServiceImpl.kt
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
+5
-5
MsgViewHolderCustomerServiceCard.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderCustomerServiceCard.java
+2
-4
MsgViewHolderRecommendAssistant.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderRecommendAssistant.java
+2
-1
MsgViewHolderRecommendExpertList.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderRecommendExpertList.java
+2
-1
YDLMessageFragment.java
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
+6
-1
No files found.
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
View file @
4733f993
...
...
@@ -20,8 +20,8 @@ import java.util.List;
public
final
class
DemoGlobalConfig
implements
IConfigModule
{
String
APP_DOMAIN
=
"https://api.github.com/"
;
// public static String appEnv = YDLConstants.ENV_AUTO_TEST;
public
static
String
appEnv
=
YDLConstants
.
ENV_TEST
;
//
public static String appEnv = YDLConstants.ENV_PROD;
//
public static String appEnv = YDLConstants.ENV_TEST;
public
static
String
appEnv
=
YDLConstants
.
ENV_PROD
;
@Override
public
void
injectAppLifecycle
(
@NotNull
Context
context
,
@NotNull
List
<
IAppLifecycles
>
lifecycles
)
{
...
...
m-im/src/main/java/com/yidianling/im/helper/IMChatUtil.kt
View file @
4733f993
...
...
@@ -11,6 +11,8 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse
import
com.ydl.ydlcommon.data.http.BaseResponse
import
com.ydl.ydlcommon.data.http.RxUtils.applySchedulers
import
com.ydl.ydlcommon.data.http.UpLoadLogUtils.upLoadLog
import
com.ydl.ydlcommon.ui.LoadingDialogFragment
import
com.ydl.ydlcommon.ui.LoadingDialogFragment.Companion.newInstance
import
com.ydl.ydlcommon.utils.NetworkParamsUtils
import
com.ydl.ydlcommon.utils.UserInfoCache
import
com.ydl.ydlcommon.utils.remind.HttpErrorUtils.Companion.handleError
...
...
@@ -19,6 +21,7 @@ import com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.R
import
com.yidianling.im.api.bean.IMExpertBuild
import
com.yidianling.im.bean.DoctorAssistantRespDtoBean
import
com.yidianling.im.bean.GetExpert
import
com.yidianling.im.bean.UserTypeBean
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
...
...
@@ -42,44 +45,33 @@ import retrofit2.HttpException
import
java.net.URLEncoder
/**
* Created by Jim on 2017/12/13 0013.
* 聊天接口封装
* 私聊页面相关接口封装
*/
object
IMChatUtil
{
private
var
loadingDialog
:
LoadingDialogFragment
?
=
null
/**
* 接口数据请求完成回调
*/
interface
ChatDataRequestListener
{
fun
onSuccess
()
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
}
// private var dialog: LoadingDialogFragment? = null
fun
showSilencedDialog
(
context
:
Context
,
tips
:
String
?,
url
:
String
?
)
{
CommonDialog
.
create
(
context
)
.
setMessage
(
tips
)
.
setCancelAble
(
false
)
.
setLeftOnclick
(
context
.
getString
(
R
.
string
.
im_details
)
)
{
val
realUrl
=
if
(
TextUtils
.
isEmpty
(
url
))
ImConstants
.
HELP_URL
else
url
!!
val
params
=
H5Params
(
realUrl
,
""
)
NewH5Activity
.
start
(
context
,
params
)
}
.
setRightClick
(
context
.
getString
(
R
.
string
.
im_approval
),
null
)
.
show
()
/**
* 客服专用
*/
fun
startKefuChat
(
context
:
AppCompatActivity
?)
{
SessionHelper
.
startP2PSession
(
context
,
-
1
,
"14"
,
null
,
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"14"
))
}
/**
* 私聊列表进入
* 私聊列表进入
,后置数据请求
*
* @param context
* @param chatItemBean
*/
fun
startChat
(
context
:
AppCompatActivity
?,
chatItemBean
:
ChatItemBean
)
{
SessionHelper
.
startP2PSession
(
context
,
SessionHelper
.
startP2PSession
(
context
,
chatItemBean
.
utype
,
chatItemBean
.
toUid
.
toString
(),
null
,
...
...
@@ -87,19 +79,24 @@ object IMChatUtil {
)
}
/**
* 非私聊列表进入,前置数据请求
*
* @param context
* @param toUid
* @param isFromQingShu 用于判断是否从倾诉流程跳转私聊:1:是 其他:不是 从倾述流程跳转私聊,需要发送自定义消息
*/
@SuppressLint
(
"CheckResult"
)
fun
prepareChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
fun
startChat
(
context
:
AppCompatActivity
,
toUid
:
String
,
isFromQingShu
:
Int
)
{
if
(!
isLogin
(
context
,
true
))
{
return
}
// if (d
ialog == null) {
// d
ialog = newInstance(null)
//
}
//
if (context.supportFragmentManager != null && !context.isDestroyed) {
// dialog!!
.show(context.supportFragmentManager, null)
//
}
if
(
loadingD
ialog
==
null
)
{
loadingD
ialog
=
newInstance
(
null
)
}
if
(
context
.
supportFragmentManager
!=
null
&&
!
context
.
isDestroyed
)
{
loadingDialog
?
.
show
(
context
.
supportFragmentManager
,
null
)
}
getImJavaApi
().
getUserType
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
@@ -117,150 +114,176 @@ object IMChatUtil {
res
.
data
!!
.
collectEvent
)
}
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
//专家
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
getImJavaApi
().
getChatUid
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
resp
:
BaseAPIResponse
<
DoctorAssistantRespDtoBean
>
->
val
bean
=
resp
.
data
val
toUid
=
bean
.
chatUid
prepareChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
}
})
})
{
t
:
Throwable
?
->
handleError
(
context
,
t
!!
)
}
}
else
{
prepareAssistantChatData
(
context
,
toUid
,
object
:
ChatDataRequestListener
{
override
fun
onSuccess
(
expertInfo
:
IMExpertBuild
)
{
startChatSession
(
toUid
,
expertInfo
,
isFromQingShu
,
context
)
}
})
}
}
else
{
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
ToastUtil
.
toastShort
(
res
.
msg
)
}
},
{
throwable
:
Throwable
?
->
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
!!
)
}
)
}
/**
* 开启聊天会话
*/
private
fun
startChatSession
(
toUid
:
String
,
expertInfo
:
IMExpertBuild
,
isFromQingShu
:
Int
,
context
:
AppCompatActivity
)
{
val
p2PCustomActionHandlerImpl
=
P2PCustomActionHandlerImpl
(
toUid
,
expertInfo
)
p2PCustomActionHandlerImpl
.
isFromQingShu
=
isFromQingShu
SessionHelper
.
startP2PSession
(
context
,
expertInfo
.
shareData
.
user_type
,
toUid
,
null
,
p2PCustomActionHandlerImpl
)
}
//====================准备私聊数据====================
/**
* 初始化聊天数据
*/
fun
prepareChatData
(
context
:
AppCompatActivity
,
toUid
:
String
,
listener
:
ChatDataRequestListener
)
{
if
(!
isLogin
(
context
,
true
))
{
return
}
val
dis
=
getImJavaApi
().
getUserType
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
res
:
BaseResponse
<
UserTypeBean
>
->
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
data
!!
.
chatEvent
)
{
//和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
res
.
data
!!
.
chatEvent
)
}
if
(
res
.
data
!!
.
collectEvent
)
{
//和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"collectEvent"
,
res
.
data
!!
.
collectEvent
)
}
if
(
TextUtils
.
equals
(
res
.
data
!!
.
userType
,
"2"
))
{
//接口返回值是专家,java接口
prepareExpertChatData
(
context
,
toUid
,
res
.
data
!!
.
userType
,
listener
)
prepareExpertChatData
(
context
,
toUid
,
listener
)
}
else
{
//非专家 php接口
prepareAssistantChatData
(
context
,
toUid
,
res
.
data
!!
.
userType
,
listener
)
prepareAssistantChatData
(
context
,
toUid
,
listener
)
}
}
else
{
// if (d
ialog!!.isVisible) {
// dialog!!
.dismissAllowingStateLoss()
//
}
if
(
loadingDialog
!=
null
&&
loadingD
ialog
!!
.
isVisible
)
{
loadingDialog
?
.
dismissAllowingStateLoss
()
}
ToastUtil
.
toastShort
(
res
.
msg
)
}
},
{
throwable
:
Throwable
?
->
// if (dialog!!.isVisible) {
// dialog!!.dismissAllowingStateLoss()
// }
},
{
throwable
:
Throwable
?
->
if
(
loadingDialog
!=
null
&&
loadingDialog
!!
.
isVisible
)
{
loadingDialog
?.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
!!
)
}
)
}
/**
* 专家私聊
* 专家私聊
数据请求
*/
fun
prepareExpertChatData
(
context
:
AppCompatActivity
,
toUid
:
String
?,
userType
:
String
?,
listener
:
ChatDataRequestListener
)
{
fun
prepareExpertChatData
(
context
:
AppCompatActivity
,
toUid
:
String
?,
listener
:
ChatDataRequestListener
)
{
val
disposable
=
getImJavaApi
().
getPersonalChat
(
toUid
!!
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
{
resp
:
BaseResponse
<
IMExpertBuild
>
->
// if (null != dialog && dialog!!.isVisible) {
// dialog!!.dismissAllowingStateLoss()
// }
.
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
)
val
handler
=
P2PCustomActionHandlerImpl
(
toUid
,
expert
)
handler
.
userType
=
userType
!!
.
toInt
()
ActionHandlerStorage
.
setL
(
toUid
,
handler
)
listener
.
onSuccess
()
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
)
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
}
else
{
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
}
)
{
throwable
:
Throwable
->
// if (null != dialog && d
ialog!!.isVisible) {
// dialog!!
.dismissAllowingStateLoss()
//
}
if
(
null
!=
loadingDialog
&&
loadingD
ialog
!!
.
isVisible
)
{
loadingDialog
?
.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
)
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
,
userType
:
String
,
listener
:
ChatDataRequestListener
)
{
val
cmd
=
GetExpert
(
toUid
.
toInt
(),
0
)
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 != dialog && dialog!!.isVisible) {
// dialog!!.dismissAllowingStateLoss()
// }
.
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
)
val
handler
=
P2PCustomActionHandlerImpl
(
toUid
,
expert
)
handler
.
userType
=
userType
.
toInt
()
ActionHandlerStorage
.
setL
(
toUid
,
handler
)
listener
?.
onSuccess
()
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
)
showSilencedDialog
(
context
,
resp
.
data
.
tips
,
resp
.
data
.
url
)
}
else
{
ToastUtil
.
toastShort
(
resp
.
msg
)
}
}
}
)
{
throwable
:
Throwable
->
// if (null != dialog && dialog!!.isVisible
) {
// dialog!!
.dismissAllowingStateLoss()
//
}
if
(
null
!=
loadingDialog
&&
loadingDialog
?.
isVisible
!!
)
{
loadingDialog
?
.
dismissAllowingStateLoss
()
}
handleError
(
context
,
throwable
)
if
(
throwable
is
HttpException
)
{
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
upLoadLog
(
"consult/get-expert"
,
throwable
.
code
(),
throwable
.
message
!!
)
}
}
}
//====================私聊页面 初始化操作====================
/**
* 初始化在线状态接口
*/
fun
initChatOnlineState
(
tb
:
TitleBarBottom
,
context
:
Context
,
toUid
:
String
)
{
val
actionHandler
=
ActionHandlerStorage
.
getL
(
toUid
)
//获取私聊对方在线状态
...
...
@@ -273,16 +296,13 @@ object IMChatUtil {
// 调取接口获取专家状态
val
dis
=
instance
.
getDoctorChatStatus
(
actionHandler
.
info
.
toUid
.
toLong
())
.
compose
(
applySchedulers
()
)
.
compose
(
applySchedulers
())
.
subscribe
(
{
chatStatusBean
:
BaseAPIResponse
<
ChatStatusBean
>
->
if
(
actionHandler
!=
null
)
{
val
status
=
chatStatusBean
.
data
.
status
actionHandler
.
setDoctorStatus
(
status
)
actionHandler
.
setDoctorBusyNum
(
chatStatusBean
.
data
.
busyTotal
)
actionHandler
.
setDoctorBusyNum
(
chatStatusBean
.
data
.
busyTotal
)
//1.在线,2.离线,3.忙碌 4咨询中, 5倾述中 6咨询前准备
if
(
status
==
2
)
{
//离线
tb
.
setMinTitleText
(
"离线"
)
...
...
@@ -297,12 +317,7 @@ object IMChatUtil {
tb
.
setMinTitleColor
(
context
.
getResources
().
getColor
(
R
.
color
.
platform_color_666666
))
tb
.
setMinTitleDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_chat_top_status_online
))
}
initSystemMessage
(
chatStatusBean
.
data
.
promptRule
,
status
,
toUid
,
actionHandler
)
initSystemMessage
(
chatStatusBean
.
data
.
promptRule
,
status
,
toUid
,
actionHandler
)
}
}
)
{
throwable
:
Throwable
->
...
...
@@ -315,8 +330,7 @@ object IMChatUtil {
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
{
res
:
BaseAPIResponse
<
Int
>
->
.
subscribe
({
res
:
BaseAPIResponse
<
Int
>
->
if
(
actionHandler
!=
null
)
{
if
(
res
.
data
==
1
)
{
//在线
tb
.
setMinTitleText
(
"在线"
)
...
...
@@ -339,12 +353,7 @@ object IMChatUtil {
// 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
))
{
val
showExpertList
=
!(
promptRule
==
1
||
promptRule
==
3
)
if
(
actionHandler
.
userType
==
2
&&
status
==
2
)
{
//当该专家离线时
...
...
@@ -359,33 +368,29 @@ object IMChatUtil {
* 发送推荐专家列表
*/
@SuppressLint
(
"CheckResult"
)
fun
sendRecommendExpertListMessage
(
type
:
Int
,
showExpertList
:
Boolean
,
toUid
:
String
,
actionHandler
:
IP2PCustomActionHandler
)
{
// 调取接口获取推荐专家列表
instance
.
getRecommendExpertList
(
actionHandler
.
info
.
toUid
.
toLong
(),
URLEncoder
.
encode
(
actionHandler
.
info
.
tag1
),
3
)
fun
sendRecommendExpertListMessage
(
type
:
Int
,
showExpertList
:
Boolean
,
toUid
:
String
,
actionHandler
:
IP2PCustomActionHandler
)
{
// 调取接口获取推荐专家列表
instance
.
getRecommendExpertList
(
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
())
actionHandler
.
sendRecommendExpertListMessage
(
toUid
,
res
.
data
,
type
,
showExpertList
)
},
{
throwable
:
Throwable
->
ToastUtil
.
toastShort
(
throwable
.
toString
())
})
}
)
}
//====================展示提示====================
fun
showSilencedDialog
(
context
:
Context
,
tips
:
String
?,
url
:
String
?)
{
CommonDialog
.
create
(
context
)
.
setMessage
(
tips
)
.
setCancelAble
(
false
)
.
setLeftOnclick
(
context
.
getString
(
R
.
string
.
im_details
)
)
{
val
realUrl
=
if
(
TextUtils
.
isEmpty
(
url
))
ImConstants
.
HELP_URL
else
url
!!
val
params
=
H5Params
(
realUrl
,
""
)
NewH5Activity
.
start
(
context
,
params
)
}
.
setRightClick
(
context
.
getString
(
R
.
string
.
im_approval
),
null
)
.
show
()
}
}
\ No newline at end of file
m-im/src/main/java/com/yidianling/im/helper/IMUtil.java
deleted
100644 → 0
View file @
11c8adb3
package
com
.
yidianling
.
im
.
helper
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.view.View
;
import
com.ydl.webview.H5Params
;
import
com.ydl.webview.NewH5Activity
;
import
com.ydl.ydlcommon.data.http.BaseResponse
;
import
com.ydl.ydlcommon.data.http.UpLoadLogUtils
;
import
com.ydl.ydlcommon.ui.LoadingDialogFragment
;
import
com.ydl.ydlcommon.utils.NetworkParamsUtils
;
import
com.ydl.ydlcommon.utils.UserInfoCache
;
import
com.ydl.ydlcommon.utils.remind.HttpErrorUtils
;
import
com.ydl.ydlcommon.view.dialog.CommonDialog
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.api.bean.IMExpertBuild
;
import
com.yidianling.im.bean.DoctorAssistantRespDtoBean
;
import
com.yidianling.im.bean.GetExpert
;
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
;
import
com.yidianling.im.config.constants.ImConstants
;
import
com.yidianling.im.http.ImRetrofitApi
;
import
com.yidianling.im.router.ImIn
;
import
com.yidianling.im.session.SessionHelper
;
import
com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.schedulers.Schedulers
;
import
retrofit2.HttpException
;
//import com.ydl.ydlcommon.dialog.CommonDialog;
/**
* Created by Jim on 2017/12/13 0013.
* 聊天接口封装
*/
public
class
IMUtil
{
public
static
final
int
FLAG_SAVE
=
0x001
;
public
static
final
int
FLAG_USE_UM
=
0x002
;
public
interface
ExpertDataFetchListener
{
void
onDataFetched
(
BaseResponse
<
IMExpertBuild
>
datas
);
}
public
static
void
startChat
(
AppCompatActivity
context
,
String
toUid
,
int
flag
,
int
canTalk
,
ExpertDataFetchListener
listener
)
{
startChat
(
context
,
toUid
,
flag
,
canTalk
,
listener
,
0
,
false
);
}
/**
* 客服专用
*/
public
static
void
startKefuChat
(
AppCompatActivity
context
,
String
toUid
,
int
flag
,
int
canTalk
,
ExpertDataFetchListener
listener
)
{
SessionHelper
.
startP2PSession
(
context
,
-
1
,
"14"
,
null
,
new
P2PCustomActionHandlerImpl
(
"14"
,
"客服小壹"
,
"14"
));
}
/**
* @param context
* @param toUid
* @param flag
* @param canTalk
* @param listener
* @param isFromQingShu 用于判断是否从倾诉流程跳转私聊:1:是 其他:不是 从倾述流程跳转私聊,需要发送自定义消息
* @param isFromMessageList 用于判断是否来自于聊天列表点击进入 true 是 false,不是
*/
@SuppressLint
(
"CheckResult"
)
public
static
void
startChat
(
AppCompatActivity
context
,
String
toUid
,
int
flag
,
int
canTalk
,
ExpertDataFetchListener
listener
,
int
isFromQingShu
,
boolean
isFromMessageList
)
{
if
(!
ImIn
.
INSTANCE
.
isLogin
(
context
,
true
))
{
return
;
}
boolean
isSaveUserInfo
=
(
flag
&
FLAG_SAVE
)
!=
0
;
boolean
isUseUm
=
(
flag
&
FLAG_USE_UM
)
!=
0
;
LogUtil
.
d
(
"isSaveUserInfo: "
+
isSaveUserInfo
+
" isUseUm: "
+
isUseUm
);
LoadingDialogFragment
dialog
=
LoadingDialogFragment
.
Companion
.
newInstance
(
null
);
if
(
context
.
getSupportFragmentManager
()
!=
null
&&
!
context
.
isDestroyed
())
{
dialog
.
show
(
context
.
getSupportFragmentManager
(),
null
);
}
GetExpert
cmd
=
new
GetExpert
(
Integer
.
parseInt
(
toUid
),
canTalk
);
ImRetrofitApi
.
Companion
.
getImJavaApi
().
getUserType
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
res
->
{
if
(
res
.
code
==
200
&&
res
.
data
!=
null
)
{
if
(
res
.
data
.
getChatEvent
())
{
//和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
res
.
data
.
getChatEvent
());
}
if
(
res
.
data
.
getCollectEvent
())
{
//和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"collectEvent"
,
res
.
data
.
getCollectEvent
());
}
if
(
TextUtils
.
equals
(
res
.
data
.
getUserType
(),
"2"
))
{
//专家
if
(
isFromMessageList
)
{
startExpertChat
(
context
,
toUid
,
dialog
,
listener
,
isUseUm
,
isSaveUserInfo
,
isFromQingShu
);
return
;
}
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
ImRetrofitApi
.
Companion
.
getImJavaApi
().
getChatUid
((
toUid
))
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
resp
->
{
DoctorAssistantRespDtoBean
bean
=
resp
.
data
;
ImRetrofitApi
.
Companion
.
getImJavaApi
().
getUserType
(
bean
.
chatUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
userTypeResp
->
{
if
(
userTypeResp
.
code
==
200
&&
userTypeResp
.
data
!=
null
)
{
if
(
userTypeResp
.
data
.
getChatEvent
())
{
//和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"chatEvent"
,
userTypeResp
.
data
.
getChatEvent
());
}
if
(
userTypeResp
.
data
.
getCollectEvent
())
{
//和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper
.
setStatusCache
(
"collectEvent"
,
userTypeResp
.
data
.
getCollectEvent
());
}
if
(
TextUtils
.
equals
(
userTypeResp
.
data
.
getUserType
(),
"2"
))
{
//专家 java 接口
//接口返回值是专家,java接口
startExpertChat
(
context
,
bean
.
chatUid
,
dialog
,
listener
,
isUseUm
,
isSaveUserInfo
,
isFromQingShu
);
}
else
{
//非专家 php接口
GetExpert
cmd1
=
new
GetExpert
(
Integer
.
parseInt
(
bean
.
chatUid
),
canTalk
);
startAssistantChat
(
context
,
bean
.
chatUid
,
cmd1
,
dialog
,
listener
,
isUseUm
,
isSaveUserInfo
,
isFromQingShu
);
}
}
else
{
if
(
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
ToastUtil
.
toastShort
(
userTypeResp
.
msg
);
}
},
throwable
->
{
if
(
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
HttpErrorUtils
.
Companion
.
handleError
(
context
,
throwable
);
});
},
t
->
{
HttpErrorUtils
.
Companion
.
handleError
(
context
,
t
);
});
}
else
{
startAssistantChat
(
context
,
toUid
,
cmd
,
dialog
,
listener
,
isUseUm
,
isSaveUserInfo
,
isFromQingShu
);
}
}
else
{
if
(
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
ToastUtil
.
toastShort
(
res
.
msg
);
}
},
throwable
->
{
if
(
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
HttpErrorUtils
.
Companion
.
handleError
(
context
,
throwable
);
});
}
/**
* 专家私聊
*/
public
static
void
startExpertChat
(
AppCompatActivity
context
,
String
toUid
,
LoadingDialogFragment
dialog
,
ExpertDataFetchListener
listener
,
boolean
isUseUm
,
boolean
isSaveUserInfo
,
int
isFromQingShu
)
{
Disposable
disposable
=
ImRetrofitApi
.
Companion
.
getImJavaApi
().
getPersonalChat
(
toUid
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
resp
->
{
if
(
null
!=
dialog
&&
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
if
(
listener
!=
null
)
{
listener
.
onDataFetched
(
resp
);
return
;
}
if
(
resp
.
code
==
200
)
{
IMExpertBuild
expert
=
resp
.
data
;
if
(
isSaveUserInfo
)
{
UserInfoCache
.
getInstance
().
saveYDLUser
(
expert
.
shareData
.
toUid
,
expert
.
shareData
.
doctorName
,
expert
.
shareData
.
cover
);
}
P2PCustomActionHandlerImpl
P2PCustomActionHandlerImpl
=
new
P2PCustomActionHandlerImpl
(
toUid
,
expert
);
P2PCustomActionHandlerImpl
.
isFromQingShu
=
isFromQingShu
;
SessionHelper
.
startP2PSession
(
context
,
expert
.
shareData
.
user_type
,
toUid
,
null
,
P2PCustomActionHandlerImpl
);
}
else
{
UpLoadLogUtils
.
INSTANCE
.
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
);
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
context
.
startActivity
(
ImIn
.
INSTANCE
.
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
->
{
if
(
null
!=
dialog
&&
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
HttpErrorUtils
.
Companion
.
handleError
(
context
,
throwable
);
if
(
throwable
instanceof
HttpException
)
{
UpLoadLogUtils
.
INSTANCE
.
upLoadLog
(
"consult/get-expert"
,
((
HttpException
)
throwable
).
code
(),
throwable
.
getMessage
());
}
});
}
/**
* 助理私聊
*/
public
static
void
startAssistantChat
(
AppCompatActivity
context
,
String
toUid
,
GetExpert
cmd
,
LoadingDialogFragment
dialog
,
ExpertDataFetchListener
listener
,
boolean
isUseUm
,
boolean
isSaveUserInfo
,
int
isFromQingShu
)
{
Disposable
disposable
=
ImRetrofitApi
.
Companion
.
getImRetrofitApi
().
getExpert
(
NetworkParamsUtils
.
getMaps
(
cmd
)).
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
resp
->
{
if
(
null
!=
dialog
&&
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
if
(
listener
!=
null
)
{
listener
.
onDataFetched
(
resp
);
return
;
}
if
(
resp
.
code
==
0
)
{
IMExpertBuild
expert
=
resp
.
data
;
if
(
isSaveUserInfo
)
{
UserInfoCache
.
getInstance
().
saveYDLUser
(
expert
.
shareData
.
toUid
,
expert
.
shareData
.
doctorName
,
expert
.
shareData
.
cover
);
}
P2PCustomActionHandlerImpl
p2PCustomActionHandlerImpl
=
new
P2PCustomActionHandlerImpl
(
toUid
,
expert
);
p2PCustomActionHandlerImpl
.
isFromQingShu
=
isFromQingShu
;
SessionHelper
.
startP2PSession
(
context
,
expert
.
shareData
.
user_type
,
toUid
,
null
,
p2PCustomActionHandlerImpl
);
}
else
{
UpLoadLogUtils
.
INSTANCE
.
upLoadLog
(
"consult/get-expert"
,
resp
.
code
,
resp
.
msg
);
if
(
resp
.
code
==
ImConstants
.
HTTP_CODE_UNLOGIN
)
{
context
.
startActivity
(
ImIn
.
INSTANCE
.
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
->
{
if
(
null
!=
dialog
&&
dialog
.
isVisible
())
{
dialog
.
dismissAllowingStateLoss
();
}
HttpErrorUtils
.
Companion
.
handleError
(
context
,
throwable
);
if
(
throwable
instanceof
HttpException
)
{
UpLoadLogUtils
.
INSTANCE
.
upLoadLog
(
"consult/get-expert"
,
((
HttpException
)
throwable
).
code
(),
throwable
.
getMessage
());
}
});
}
public
static
void
showSilencedDialog
(
Context
context
,
String
tips
,
String
url
)
{
CommonDialog
.
create
(
context
)
.
setMessage
(
tips
)
.
setLeftOnclick
(
context
.
getString
(
R
.
string
.
im_details
),
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
String
realUrl
=
TextUtils
.
isEmpty
(
url
)
?
ImConstants
.
HELP_URL
:
url
;
H5Params
params
=
new
H5Params
(
realUrl
,
""
);
NewH5Activity
.
start
(
context
,
params
);
}
})
.
setRightClick
(
context
.
getString
(
R
.
string
.
im_approval
),
null
)
.
show
();
}
}
m-im/src/main/java/com/yidianling/im/modular/service/IMServiceImpl.kt
View file @
4733f993
...
...
@@ -27,7 +27,7 @@ import com.yidianling.im.api.listener.ApiStringResponseCallback
import
com.yidianling.im.api.service.IImService
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
import
com.yidianling.im.config.NimApplication
import
com.yidianling.im.helper.IMUtil
import
com.yidianling.im.helper.IM
Chat
Util
import
com.yidianling.im.helper.LogoutHelper
import
com.yidianling.im.helper.MsgReceiveHelper
import
com.yidianling.im.http.ImRetrofitApi
...
...
@@ -60,7 +60,7 @@ class IMServiceImpl : IImService {
}
override
fun
startP2PSession
(
context
:
Activity
,
toUid
:
String
)
{
IM
Util
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
IMUtil
.
FLAG_SAVE
or
IMUtil
.
FLAG_USE_UM
,
0
,
null
)
IM
ChatUtil
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
0
)
}
override
fun
startP2PXiaoYi
(
context
:
Context
)
{
...
...
@@ -210,12 +210,12 @@ class IMServiceImpl : IImService {
*/
override
fun
startChat
(
context
:
Activity
,
toUid
:
String
,
flag
:
Int
,
canTalk
:
Int
)
{
//这里虽然是倾述流程进入私聊,但不需要发送自定义消息
IM
Util
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
0
x001
,
canTalk
,
null
,
0
,
false
)
IM
ChatUtil
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
0
)
}
override
fun
startChat
(
context
:
Activity
,
toUid
:
String
,
flag
:
Int
,
canTalk
:
Int
,
isFramQingsu
:
Int
,
isFromMessageList
:
Boolean
)
{
//这里虽然是倾述流程进入私聊,但不需要发送自定义消息
IM
Util
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
0
x001
,
canTalk
,
null
,
isFramQingsu
,
isFromMessageList
)
IM
ChatUtil
.
startChat
(
context
as
AppCompatActivity
,
toUid
,
isFramQingsu
)
}
override
fun
getUnReadByUid
(
uid
:
String
):
Int
{
...
...
@@ -268,7 +268,7 @@ class IMServiceImpl : IImService {
}
override
fun
startKefuChat
(
context
:
Context
,
toUid
:
String
,
flag
:
Int
,
canTalk
:
Int
)
{
IM
Util
.
startKefuChat
(
context
as
AppCompatActivity
,
toUid
,
flag
,
canTalk
,
null
)
IM
ChatUtil
.
startKefuChat
(
context
as
AppCompatActivity
)
}
override
fun
startP2PSession
(
mContext
:
Context
,
userType
:
Int
,
account
:
String
,
toChatUsername
:
String
,
toName
:
String
,
head
:
String
)
{
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderCustomerServiceCard.java
View file @
4733f993
...
...
@@ -4,8 +4,7 @@ import android.support.v7.app.AppCompatActivity;
import
android.widget.LinearLayout
;
import
com.yidianling.im.R
;
import
com.yidianling.im.helper.IMUtil
;
import
com.yidianling.im.session.SessionHelper
;
import
com.yidianling.im.helper.IMChatUtil
;
import
com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter
;
import
com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase
;
...
...
@@ -45,7 +44,6 @@ public class MsgViewHolderCustomerServiceCard extends MsgViewHolderBase {
@Override
protected
void
onItemClick
()
{
super
.
onItemClick
();
IMUtil
.
startKefuChat
((
AppCompatActivity
)
context
,
"14"
,
IMUtil
.
FLAG_SAVE
|
IMUtil
.
FLAG_USE_UM
,
0
,
null
);
IMChatUtil
.
INSTANCE
.
startKefuChat
((
AppCompatActivity
)
context
);
}
}
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderRecommendAssistant.java
View file @
4733f993
...
...
@@ -7,6 +7,7 @@ import android.widget.TextView;
import
com.ydl.ydl_image.module.GlideApp
;
import
com.ydl.ydlcommon.base.BaseApp
;
import
com.yidianling.im.R
;
import
com.yidianling.im.helper.IMChatUtil
;
import
com.yidianling.im.helper.IMUtil
;
import
com.yidianling.im.session.extension.CustomAttachmentRecommendAssistant
;
import
com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter
;
...
...
@@ -81,7 +82,7 @@ public class MsgViewHolderRecommendAssistant extends MsgViewHolderBase {
@Override
protected
void
onItemClick
()
{
try
{
IM
Util
.
startChat
((
AppCompatActivity
)
context
,
touid
,
0
,
0
,
null
,
0
,
false
);
IM
ChatUtil
.
INSTANCE
.
startChat
((
AppCompatActivity
)
context
,
touid
,
0
);
}
catch
(
NumberFormatException
e
)
{
e
.
printStackTrace
();
}
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderRecommendExpertList.java
View file @
4733f993
...
...
@@ -12,6 +12,7 @@ import com.ydl.ydl_image.module.GlideApp;
import
com.ydl.ydlcommon.utils.AnimUtils
;
import
com.yidianling.im.R
;
import
com.yidianling.im.bean.DoctorAssistantRespDtoBean
;
import
com.yidianling.im.helper.IMChatUtil
;
import
com.yidianling.im.helper.IMUtil
;
import
com.yidianling.im.http.ImRetrofitApi
;
import
com.yidianling.im.session.extension.CustomRecommendExpertListMsg
;
...
...
@@ -83,7 +84,7 @@ public class MsgViewHolderRecommendExpertList extends MsgViewHolderBase {
if
(
String
.
valueOf
(
bean
.
chatUid
).
equals
(
toUid
))
{
ActionHandlerStorage
.
getL
(
message
.
getSessionId
()).
judgeSendRemindMsg
(
message
.
getSessionId
());
}
else
{
IM
Util
.
startChat
((
AppCompatActivity
)
context
,
toUid
,
IMUtil
.
FLAG_SAVE
|
IMUtil
.
FLAG_USE_UM
,
0
,
null
);
IM
ChatUtil
.
INSTANCE
.
startChat
((
AppCompatActivity
)
context
,
toUid
,
0
);
}
});
...
...
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
View file @
4733f993
...
...
@@ -54,6 +54,7 @@ import com.ydl.ydlcommon.view.CircleImageView;
import
com.ydl.ydlcommon.view.dialog.CommonDialog
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.bridge.P2PCustomActionHandlerImpl
;
import
com.yidianling.im.helper.IMChatUtil
;
import
com.yidianling.im.router.ImIn
;
import
com.yidianling.nimbase.api.UIKitOptions
;
...
...
@@ -252,7 +253,11 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
if
(
ActionHandlerStorage
.
getL
(
sessionId
).
isNotPrepare
())
{
IMChatUtil
.
INSTANCE
.
prepareChatData
((
AppCompatActivity
)
getActivity
(),
sessionId
,
()
->
{
IMChatUtil
.
INSTANCE
.
prepareChatData
((
AppCompatActivity
)
getActivity
(),
sessionId
,
(
expertInfo
)
->
{
String
toUid
=
expertInfo
.
shareData
.
toUid
;
P2PCustomActionHandlerImpl
handler
=
new
P2PCustomActionHandlerImpl
(
toUid
,
expertInfo
);
handler
.
setUserType
(
expertInfo
.
shareData
.
user_type
);
ActionHandlerStorage
.
setL
(
toUid
,
handler
);
initView
();
});
}
else
{
...
...
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