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
6233367b
Commit
6233367b
authored
Jul 01, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:更新本地消息
parent
6302007a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
47 deletions
+93
-47
MultipleSelectedEvent.kt
m-im/src/main/java/com/yidianling/im/event/MultipleSelectedEvent.kt
+0
-1
ImIn.kt
m-im/src/main/java/com/yidianling/im/router/ImIn.kt
+9
-0
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+44
-42
LingxiWhichQuestionBean.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
+8
-2
YDLMessageFragment.java
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
+32
-2
No files found.
m-im/src/main/java/com/yidianling/im/event/MultipleSelectedEvent.kt
View file @
6233367b
package
com.yidianling.im.event
import
com.yidianling.im.router.ImIn.getUserInfo
import
com.yidianling.im.session.viewholder.bean.AnswersItem
public
class
MultipleSelectedEvent
(
...
...
m-im/src/main/java/com/yidianling/im/router/ImIn.kt
View file @
6233367b
...
...
@@ -9,6 +9,7 @@ import com.netease.nimlib.sdk.NIMClient
import
com.netease.nimlib.sdk.RequestCallback
import
com.netease.nimlib.sdk.auth.LoginInfo
import
com.netease.nimlib.sdk.msg.MsgService
import
com.netease.nimlib.sdk.msg.model.IMMessage
import
com.netease.nimlib.sdk.uinfo.UserService
import
com.netease.nimlib.sdk.uinfo.constant.UserInfoFieldEnum
import
com.ydl.confide.api.IConfideService
...
...
@@ -301,4 +302,12 @@ object ImIn {
fun
loginByOneKeyLogin
(
context
:
Context
,
isOpenDialog
:
Boolean
)
:
Boolean
{
return
getUserService
().
loginByOneKeyLogin
(
context
,
isOpenDialog
)
}
lateinit
var
imMessage
:
IMMessage
fun
setLocalExten
(
imMessage
:
IMMessage
){
this
.
imMessage
=
imMessage
}
fun
getImmessage
():
IMMessage
{
return
imMessage
}
}
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
6233367b
package
com
.
yidianling
.
im
.
session
.
viewholder
;
import
android.content.ContextWrapper
;
import
android.os.Build
;
import
android.view.View
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.GridLayoutManager
;
...
...
@@ -17,7 +15,6 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import
com.netease.nimlib.sdk.msg.model.IMMessage
;
import
com.ydl.ydlcommon.data.http.RxUtils
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.event.MultipleAnswerBean
;
import
com.yidianling.im.event.MultipleSelectedEvent
;
...
...
@@ -70,6 +67,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private
String
questionPaperId
;
private
String
questionId
;
private
ArrayList
<
AnswersItem
>
answersItems
=
new
ArrayList
<>();
private
ArrayList
<
String
>
answersItemsMap
=
new
ArrayList
<>();
private
ArrayList
<
String
>
multipleAnswers
=
new
ArrayList
<>();
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
...
...
@@ -107,6 +106,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected
void
bindContentView
()
{
ImIn
.
INSTANCE
.
setImMessage
(
message
);
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
examId
=
customAttachLingxiWhichQuestion
.
examId
;
questionPaperId
=
customAttachLingxiWhichQuestion
.
questionPaperId
;
...
...
@@ -150,6 +150,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
map
!=
null
)
{
Object
obj
=
map
.
get
(
"isSure"
);
Object
position
=
map
.
get
(
"position"
);
Object
multiple
=
map
.
get
(
"multiple"
);
if
(
obj
!=
null
)
{
boolean
b
=
(
boolean
)
obj
;
...
...
@@ -157,26 +158,55 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
b
)
{
//不可点击
isClickable
=
false
;
if
(
posi
!=
null
){
questionList
.
get
(
posi
).
setSelected
(
true
);
}
}
}
else
{
//可点击
}
if
(
multiple
!=
null
){
multipleAnswers
=
(
ArrayList
<
String
>)
multiple
;
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
for
(
int
j
=
0
;
j
<
multipleAnswers
.
size
();
j
++){
if
(
questionList
.
get
(
i
).
getName
().
contains
(
multipleAnswers
.
get
(
j
))){
questionList
.
get
(
i
).
setSelected
(
true
);
}
}
}
if
(
isClickable
){
confirm_multiple_choice
.
setEnabled
(
true
);
confirm_multiple_choice
.
setBackground
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_18dp_ebebeb
));
}
else
{
confirm_multiple_choice
.
setEnabled
(
false
);
confirm_multiple_choice
.
setBackground
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_18dp_1da1f2
));
confirm_multiple_choice
.
setText
(
"确定("
+
multipleAnswers
.
size
()+
")"
);
}
}
}
else
{
//可点击
}
}
catch
(
Exception
e
)
{
LogUtil
.
e
(
"aaaaa"
+
e
.
getLocalizedMessage
());
}
}
private
void
initMultipleChoice
()
{
confirm_multiple_choice
.
setOnClickListener
(
view
->
{
//请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。
EventBus
.
getDefault
().
post
(
new
MultipleSelectedEvent
(
null
,
null
,
new
MultipleAnswerBean
(
examId
,
questionPaperId
,
ImIn
.
INSTANCE
.
getUserInfo
().
getUid
(),
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
));
/* for (int i=0;i<answersItems.size();i++){
answersItemsMap.add(answersItems.get(i).getName());
}
updateLocalMsg(null,answersItemsMap);*/
});
multiple_choice_title
.
setText
(
customAttachLingxiWhichQuestion
.
name
);
adapterLingxiMultipleChoice
=
new
AdapterLingxiMultipleChoice
();
...
...
@@ -215,7 +245,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
//请求接口发送所选题目
answerLingxiQuestion
(
examId
,
questionPaperId
,
ImIn
.
INSTANCE
.
getUserInfo
().
getUid
().
toString
(),
questionId
,
answersItems
);
//更新本地消息
updateLocalMsg
(
position
);
updateLocalMsg
(
position
,
null
);
}
}
...
...
@@ -224,7 +254,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
* 用户回答问题接口
* */
private
void
answerLingxiQuestion
(
String
examID
,
String
questionPaperId
,
String
uid
,
String
questionId
,
ArrayList
<
AnswersItem
>
answersItems
)
{
String
str
=
new
Gson
().
toJson
(
new
LingxiAnswerBean
(
new
AnswerBean
(
examID
,
questionPaperId
,
uid
,
questionId
,
answersItems
),
message
.
getFromAccount
(),
"56"
,
uid
));
String
str
=
new
Gson
().
toJson
(
new
LingxiAnswerBean
(
new
AnswerBean
(
examID
,
questionPaperId
,
uid
,
questionId
,
answersItems
),
uid
,
"56"
,
message
.
getFromAccount
()
));
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
str
);
Disposable
subscribe
=
ImRetrofitApi
.
Companion
.
getImRetrofitApi
().
lingxiAnswerQuestion
(
body
)
.
compose
(
RxUtils
.
INSTANCE
.
resultJavaData
())
...
...
@@ -240,6 +270,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
public
void
onMultipleItemClick
(
@NotNull
QuestionItemBean
string
,
int
position
)
{
if
(
isClickable
){
//多选发送消息
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++)
{
if
(
questionList
.
get
(
i
).
isSelected
())
{
...
...
@@ -284,54 +315,25 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
EventBus
.
getDefault
().
post
(
new
MultipleSelectedEvent
(
stringBuffer
.
toString
(),
new
OthersState
(
isOthers
,
questionList
.
get
(
position
).
isSelected
()),
new
MultipleAnswerBean
(
examId
,
questionPaperId
,
ImIn
.
INSTANCE
.
getUserInfo
().
getUid
(),
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
));
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
}
}
private
void
updateLocalMsg
(
Integer
position
)
{
private
void
updateLocalMsg
(
Integer
position
,
ArrayList
<
String
>
selectedPosition
)
{
//更新本地消息
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
if
(
map
==
null
)
{
map
=
new
HashMap
();
}
map
.
put
(
"isSure"
,
true
);
if
(
position
!=
null
){
map
.
put
(
"position"
,
position
);
}
if
(
selectedPosition
!=
null
){
map
.
put
(
"multiple"
,
selectedPosition
);
}
message
.
setLocalExtension
(
map
);
NIMClient
.
getService
(
MsgService
.
class
).
updateIMMessage
(
message
);
//同时更新历史同订单未确认的消息状态
NIMClient
.
getService
(
MsgService
.
class
).
queryMessageList
(
message
.
getSessionId
(),
SessionTypeEnum
.
P2P
,
0
,
100
).
setCallback
(
new
RequestCallback
<
List
<
IMMessage
>>()
{
@Override
public
void
onSuccess
(
List
<
IMMessage
>
param
)
{
if
(
param
!=
null
&&
param
.
size
()
>
0
)
{
for
(
IMMessage
msg
:
param
)
{
MsgAttachment
attachment
=
msg
.
getAttachment
();
if
(
attachment
instanceof
CustomAttachLingxiWhichQuestion
)
{
Map
map1
=
msg
.
getLocalExtension
();
if
(
map1
==
null
)
{
map1
=
new
HashMap
();
map1
.
put
(
"isExpired"
,
true
);
map1
.
put
(
"position"
,
position
);
msg
.
setLocalExtension
(
map1
);
NIMClient
.
getService
(
MsgService
.
class
).
updateIMMessage
(
msg
);
//通知ui刷新
getMsgAdapter
().
updateItemAtLocalExtension
(
msg
);
}
}
}
}
}
@Override
public
void
onFailed
(
int
code
)
{
getMsgAdapter
().
updateItemAtLocalExtension
(
message
);
}
@Override
public
void
onException
(
Throwable
exception
)
{
}
});
}
}
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
View file @
6233367b
package
com.yidianling.im.session.viewholder.bean
import
android.os.Parcel
import
android.os.Parcelable
import
java.io.Serializable
data class
LingxiWhichQuestionBean
(
var
isSelected
:
Boolean
,
...
...
@@ -30,18 +34,20 @@ data class AnswerBean(
var
questionId
:
String
,
var
answers
:
ArrayList
<
AnswersItem
>
)
data
class
AnswersItem
(
class
AnswersItem
(
var
optionId
:
String
,
var
name
:
String
,
var
other
:
String
?,
var
relates
:
ArrayList
<
Relates
>
)
data class
Relates
(
class
Relates
(
var
id
:
String
?,
var
category
:
String
?,
var
name
:
String
?,
var
score
:
String
?
)
data class
UserIsIn
(
var
data
:
UserIsInPageData
,
var
fromUid
:
String
,
...
...
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
View file @
6233367b
...
...
@@ -110,6 +110,7 @@ import org.jetbrains.annotations.NotNull;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -226,6 +227,8 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private
UserInfoDialog
userInfoDialog
=
null
;
private
boolean
isOthers
;
private
MultipleAnswerBean
multipleAnswerBean
;
private
ArrayList
<
String
>
answersItemsMap
=
new
ArrayList
<>();
@SuppressLint
(
"HandlerLeak"
)
private
Handler
mHandler
=
new
Handler
()
{
@Override
...
...
@@ -1116,6 +1119,10 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
}
multipleAnswerBean
.
setAnswersItems
(
answersItems
);
for
(
int
i
=
0
;
i
<
answersItems
.
size
();
i
++){
answersItemsMap
.
add
(
i
,
answersItems
.
get
(
i
).
getName
());
}
updateLocalMsg
(
null
,
answersItemsMap
);
answerMultipleQuestion
(
multipleAnswerBean
);
}
else
{
...
...
@@ -1129,14 +1136,37 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
multipleAnswerBean
=
event
.
getMultipleAnswerBean
();
multipleAnswerBean
.
setAnswersItems
(
answersItems
);
for
(
int
i
=
0
;
i
<
answersItems
.
size
();
i
++){
answersItemsMap
.
add
(
i
,
answersItems
.
get
(
i
).
getName
());
}
updateLocalMsg
(
null
,
answersItemsMap
);
answerMultipleQuestion
(
multipleAnswerBean
);
}
}
private
void
updateLocalMsg
(
Integer
position
,
ArrayList
<
String
>
selectedPosition
)
{
IMMessage
message
=
ImIn
.
INSTANCE
.
getImMessage
();
//更新本地消息
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
if
(
map
==
null
)
{
map
=
new
HashMap
();
}
map
.
put
(
"isSure"
,
true
);
if
(
position
!=
null
){
map
.
put
(
"position"
,
position
);
}
if
(
selectedPosition
!=
null
){
map
.
put
(
"multiple"
,
selectedPosition
);
}
message
.
setLocalExtension
(
map
);
NIMClient
.
getService
(
MsgService
.
class
).
updateIMMessage
(
message
);
//通知ui刷新
// message.getMsgAdapter().updateItemAtLocalExtension(message);
}
/*
* 用户回答问题接口
* */
private
void
answerMultipleQuestion
(
MultipleAnswerBean
multipleAnswerBean
){
inputPanel
.
setInputContent
(
""
);
question_multiple
.
setText
(
""
);
inputPanel
.
onlyShowTextEnd
();
...
...
@@ -1148,7 +1178,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
* 用户回答问题接口
* */
private
void
answerLingxiQuestion
(
String
examID
,
String
questionPaperId
,
String
uid
,
String
questionId
,
ArrayList
<
AnswersItem
>
answersItems
,
String
fromUID
)
{
String
str
=
new
Gson
().
toJson
(
new
LingxiAnswerBean
(
new
AnswerBean
(
examID
,
questionPaperId
,
uid
,
questionId
,
answersItems
),
fromUID
,
"56"
,
uid
));
String
str
=
new
Gson
().
toJson
(
new
LingxiAnswerBean
(
new
AnswerBean
(
examID
,
questionPaperId
,
uid
,
questionId
,
answersItems
),
uid
,
"56"
,
fromUID
));
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
str
);
Disposable
subscribe
=
ImRetrofitApi
.
Companion
.
getImRetrofitApi
().
lingxiAnswerQuestion
(
body
)
.
compose
(
RxUtils
.
INSTANCE
.
resultJavaData
())
...
...
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