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
5d070de9
Commit
5d070de9
authored
Jun 24, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:im-灵犀2.0-更新本地消息
parent
a358fcc2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
13 deletions
+111
-13
CustomAttachLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/extension/CustomAttachLingxiWhichQuestion.java
+3
-0
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+104
-9
AdapterLingxiMultipleChoice.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiMultipleChoice.kt
+1
-1
AdapterLingxiWhichQuestion.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
+1
-2
LingxiWhichQuestionBean.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
+2
-1
No files found.
m-im/src/main/java/com/yidianling/im/session/extension/CustomAttachLingxiWhichQuestion.java
View file @
5d070de9
...
...
@@ -2,6 +2,7 @@ package com.yidianling.im.session.extension;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
;
import
com.yidianling.im.session.viewholder.bean.QuestionItemBean
;
import
com.yidianling.uikit.custom.http.response.RecommendExpertBean
;
...
...
@@ -36,6 +37,7 @@ public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
this
.
questionId
=
data
.
getString
(
QUESTIONID
);
this
.
questionTitle
=
data
.
getString
(
QUESTIONTITLE
);
this
.
selectType
=
data
.
getString
(
SELECTTYPE
);
LogUtil
.
e
(
"aaaaa"
+
data
.
getString
(
SELECTVALS
));
this
.
selectVals
=(
ArrayList
<
QuestionItemBean
>)
JSON
.
parseArray
(
data
.
getString
(
SELECTVALS
),
QuestionItemBean
.
class
);
}
...
...
@@ -51,4 +53,5 @@ public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
data
.
put
(
SELECTVALS
,
selectVals
);
return
data
;
}
}
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
5d070de9
...
...
@@ -2,15 +2,23 @@ package com.yidianling.im.session.viewholder;
import
android.widget.TextView
;
import
androidx.core.content.ContextCompat
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.netease.nimlib.sdk.NIMClient
;
import
com.netease.nimlib.sdk.RequestCallback
;
import
com.netease.nimlib.sdk.msg.MsgService
;
import
com.netease.nimlib.sdk.msg.attachment.MsgAttachment
;
import
com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
;
import
com.netease.nimlib.sdk.msg.model.IMMessage
;
import
com.yidianling.common.tools.LogUtil
;
import
com.yidianling.common.tools.ToastUtil
;
import
com.yidianling.im.R
;
import
com.yidianling.im.event.MultipleSelectedEvent
;
import
com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion
;
import
com.yidianling.im.session.extension.CustomAttachmentConfirmOrder
;
import
com.yidianling.im.session.extension.CustomAttachmentOrderStatus
;
import
com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice
;
import
com.yidianling.im.session.viewholder.adapter.AdapterLingxiWhichQuestion
;
...
...
@@ -22,6 +30,9 @@ import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
import
org.jetbrains.annotations.NotNull
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
de.greenrobot.event.EventBus
;
...
...
@@ -29,6 +40,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private
RecyclerView
recycleviewWhichQuestion
;
private
RecyclerView
recycleviewMultipleChoice
;
private
TextView
confirm_multiple_choice
;
private
TextView
which_question_title
;
private
AdapterLingxiWhichQuestion
adapterLingxiWhichQuestion
;
private
AdapterLingxiMultipleChoice
adapterLingxiMultipleChoice
;
...
...
@@ -37,6 +50,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
CustomAttachLingxiWhichQuestion
customAttachLingxiWhichQuestion
;
private
StringBuffer
stringBuffer
=
new
StringBuffer
(
"已选:"
);
ArrayList
<
String
>
selectedStr
=
new
ArrayList
<
String
>();
private
Boolean
isClickable
=
true
;
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
}
...
...
@@ -46,8 +60,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
switch
(
Integer
.
parseInt
(
customAttachLingxiWhichQuestion
.
selectType
)){
case
1
:
//您想要咨询下列哪类的问题?(单选)
//
return R.layout.im_nim_lingxi_which_question;
return
R
.
layout
.
im_nim_lingxi_multiple_choice
;
return
R
.
layout
.
im_nim_lingxi_which_question
;
//
return R.layout.im_nim_lingxi_multiple_choice;
case
2
:
//请问是发生了什么事情导致的呢?(多选)
return
R
.
layout
.
im_nim_lingxi_multiple_choice
;
case
3
:
//您是先生还是女生
...
...
@@ -62,6 +76,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewWhichQuestion
=
findViewById
(
R
.
id
.
which_question_rv
);
recycleviewMultipleChoice
=
findViewById
(
R
.
id
.
multiple_question_rv
);
confirm_multiple_choice
=
findViewById
(
R
.
id
.
confirm_multiple_choice
);
which_question_title
=
findViewById
(
R
.
id
.
which_question_title
);
}
...
...
@@ -69,19 +84,21 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
protected
void
bindContentView
()
{
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
//您想要咨询下列哪类的问题?(单选)
adapterLingxiWhichQuestion
=
new
AdapterLingxiWhichQuestion
();
for
(
int
i
=
0
;
i
<
8
;
i
++){
questionList
.
add
(
new
QuestionItemBean
(
"1"
,
"婚姻情感试"
+
i
,
false
));
if
(
customAttachLingxiWhichQuestion
.
selectVals
!=
null
){
questionList
=
(
ArrayList
<
QuestionItemBean
>)
customAttachLingxiWhichQuestion
.
selectVals
;
}
adapterLingxiWhichQuestion
=
new
AdapterLingxiWhichQuestion
();
which_question_title
.
setText
(
customAttachLingxiWhichQuestion
.
xquestionPaperName
);
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
if
(
questionList
.
get
(
i
).
getName
().
length
()>
5
){
questionList
.
get
(
i
).
setSelected
(
false
);
if
(
questionList
.
get
(
i
).
getValue
().
length
()>
5
){
isSingleChoice
=
true
;
break
;
}
}
switch
(
Integer
.
parseInt
(
customAttachLingxiWhichQuestion
.
selectType
)){
case
1
:
//您想要咨询下列哪类的问题?(单选)
if
(
questionList
!=
null
&&
questionList
.
size
()!=
0
){
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
adapterLingxiWhichQuestion
.
setItemListener
(
this
);
GridLayoutManager
gridLayoutManager
=
new
GridLayoutManager
(
context
,
2
);
...
...
@@ -90,6 +107,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
gridLayoutManager
.
setOrientation
(
GridLayoutManager
.
VERTICAL
);
recycleviewWhichQuestion
.
setLayoutManager
(
gridLayoutManager
);
recycleviewWhichQuestion
.
setAdapter
(
adapterLingxiWhichQuestion
);
}
break
;
case
2
:
//请问是发生了什么事情导致的呢?(多选)
// //请问是发生了什么事情导致的呢?(多选)
...
...
@@ -108,17 +126,45 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
default
:
break
;
}
try
{
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
if
(
map
!=
null
)
{
Object
obj
=
map
.
get
(
"isSure"
);
Object
position
=
map
.
get
(
"position"
);
if
(
obj
!=
null
)
{
boolean
b
=
(
boolean
)
obj
;
Integer
posi
=(
Integer
)
position
;
if
(
b
)
{
//不可点击
isClickable
=
false
;
questionList
.
get
(
posi
).
setSelected
(
true
);
}
}
else
{
//可点击
}
}
else
{
//可点击
}
}
catch
(
Exception
e
)
{
}
}
@Override
public
void
onItemClick
(
@NotNull
QuestionItemBean
itemBean
,
int
position
)
{
if
(
isClickable
){
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
questionList
.
get
(
i
).
setSelected
(
i
==
position
);
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
isClickable
=
false
;
//请求接口发送所选题目
updateLocalMsg
(
position
);
}
}
@Override
...
...
@@ -128,12 +174,12 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
questionList
.
get
(
i
).
isSelected
()){
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
false
);
selectedStr
.
remove
(
questionList
.
get
(
i
).
get
Nam
e
());
selectedStr
.
remove
(
questionList
.
get
(
i
).
get
Valu
e
());
}
}
else
{
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
true
);
selectedStr
.
add
(
questionList
.
get
(
i
).
get
Nam
e
());
selectedStr
.
add
(
questionList
.
get
(
i
).
get
Valu
e
());
}
}
}
...
...
@@ -145,6 +191,55 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
EventBus
.
getDefault
().
post
(
new
MultipleSelectedEvent
(
stringBuffer
.
toString
()));
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
}
private
void
updateLocalMsg
(
Integer
position
)
{
//更新本地消息
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
if
(
map
==
null
)
{
map
=
new
HashMap
();
}
map
.
put
(
"isSure"
,
true
);
map
.
put
(
"position"
,
position
);
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
)
{
CustomAttachLingxiWhichQuestion
customattachlingxiwhichquestion
=
(
CustomAttachLingxiWhichQuestion
)
attachment
;
// if (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
)
{
}
@Override
public
void
onException
(
Throwable
exception
)
{
}
});
}
}
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiMultipleChoice.kt
View file @
5d070de9
...
...
@@ -41,7 +41,7 @@ class AdapterLingxiMultipleChoice : RecyclerView.Adapter<AdapterLingxiMultipleCh
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
nam
e
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
valu
e
holder
.
tvWhichQuestion
.
setOnClickListener
{
onItemClickListener
?.
onMultipleItemClick
(
tagList
[
position
],
position
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
View file @
5d070de9
...
...
@@ -23,7 +23,6 @@ import kotlin.properties.Delegates
class
AdapterLingxiWhichQuestion
:
RecyclerView
.
Adapter
<
AdapterLingxiWhichQuestion
.
ViewHolder
>()
{
private
lateinit
var
tagList
:
List
<
QuestionItemBean
>
private
var
isSingleOrMultiple
by
Delegates
.
notNull
<
Boolean
>()
private
var
onItemClickListener
:
OnQuestionlItemClickListener
?
=
null
class
ViewHolder
(
itemView
:
View
)
:
...
...
@@ -46,7 +45,7 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
nam
e
holder
.
tvWhichQuestion
.
text
=
tagList
[
position
].
valu
e
if
(
tagList
[
position
].
isSelected
!!
){
holder
.
tvWhichQuestion
.
background
=
ContextCompat
.
getDrawable
(
holder
.
itemView
.
context
,
R
.
drawable
.
im_background_18dp_1da1f2
)
holder
.
tvWhichQuestion
.
setTextColor
(
ContextCompat
.
getColor
(
holder
.
itemView
.
context
,
R
.
color
.
white
))
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/bean/LingxiWhichQuestionBean.kt
View file @
5d070de9
...
...
@@ -13,6 +13,6 @@ data class LingxiWhichQuestionBean(
)
data class
QuestionItemBean
(
var
id
:
String
?,
var
nam
e
:
String
?,
var
valu
e
:
String
?,
var
isSelected
:
Boolean
?=
false
)
\ No newline at end of file
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