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
bb6ae476
Commit
bb6ae476
authored
Jul 08, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:滑动过程中保持选项选中状态
parent
8bccedf0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
85 deletions
+97
-85
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+97
-44
im_nim_lingxi_which_question.xml
m-im/src/main/res/layout/im_nim_lingxi_which_question.xml
+0
-41
No files found.
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
bb6ae476
...
...
@@ -58,7 +58,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
CustomAttachLingxiWhichQuestion
customAttachLingxiWhichQuestion
;
private
StringBuffer
stringBuffer
=
new
StringBuffer
(
"已选:"
);
ArrayList
<
String
>
selectedStr
=
new
ArrayList
<
String
>();
private
Boolean
isClickable
=
true
;
private
Boolean
isOthers
;
//回答试卷接口
private
String
examId
;
...
...
@@ -68,7 +67,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private
ArrayList
<
AnswersItem
>
answersItems
=
new
ArrayList
<>();
Map
<
String
,
Object
>
mapMessageFromCustom
;
Map
map1
=
new
HashMap
();
private
ArrayList
<
String
>
answeredExamid
=
new
ArrayList
<>();
private
ArrayList
<
String
>
multipleAnswers
=
new
ArrayList
<>();
private
ArrayList
<
String
>
answersItemsMap
=
new
ArrayList
<>();
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
}
...
...
@@ -76,13 +77,12 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected
int
getContentResId
()
{
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
singleOrMultipletype
=
customAttachLingxiWhichQuestion
.
type
;
singleOrMultipletype
=
customAttachLingxiWhichQuestion
.
type
;
if
(
customAttachLingxiWhichQuestion
.
type
!=
null
)
{
return
R
.
layout
.
im_nim_lingxi_multiple_choice
;
}
else
{
return
R
.
layout
.
im_nim_lingxi_
which_question
;
return
R
.
layout
.
im_nim_lingxi_
multiple_choice
;
}
}
@Override
...
...
@@ -90,7 +90,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewMultipleChoice
=
findViewById
(
R
.
id
.
multiple_question_rv
);
confirm_multiple_choice
=
findViewById
(
R
.
id
.
confirm_multiple_choice
);
multiple_choice_title
=
findViewById
(
R
.
id
.
multiple_choice_title
);
}
@Override
...
...
@@ -113,11 +112,13 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
}
if
(
customAttachLingxiWhichQuestion
.
type
!=
null
)
{
singleOrMultipletype
=
customAttachLingxiWhichQuestion
.
type
;
singleOrMultipletype
=
customAttachLingxiWhichQuestion
.
type
;
UpdateFromLocal
();
initMultipleChoice
();
}
//进入消息列表时候,保存当type为56的时候的,将ID作为key保存
NIMClient
.
getService
(
MsgService
.
class
).
queryMessageList
(
message
.
getSessionId
(),
SessionTypeEnum
.
P2P
,
0
,
100
).
setCallback
(
new
RequestCallback
<
List
<
IMMessage
>>()
{
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
)
{
...
...
@@ -126,8 +127,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
MsgAttachment
attachment
=
msg
.
getAttachment
();
if
(
attachment
instanceof
CustomAttachLingxiAnswerQuestion
)
{
CustomAttachLingxiAnswerQuestion
customattachlingxianswerquestion
=
(
CustomAttachLingxiAnswerQuestion
)
attachment
;
map1
.
put
(
customattachlingxianswerquestion
.
questionId
+
customattachlingxianswerquestion
.
examId
,
true
);
mapMessageFromCustom
=
map1
;
map1
.
put
(
customattachlingxianswerquestion
.
questionId
+
customattachlingxianswerquestion
.
examId
,
true
);
mapMessageFromCustom
=
map1
;
UpdateFromLocalExtention
();
}
}
...
...
@@ -136,39 +137,88 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
public
void
onFailed
(
int
code
)
{
LogUtil
.
e
(
"获取消息onFailed:"
+
code
);
LogUtil
.
e
(
"获取消息onFailed:"
+
code
);
}
@Override
public
void
onException
(
Throwable
exception
)
{
LogUtil
.
e
(
"获取消息exception:"
+
exception
.
getLocalizedMessage
());
LogUtil
.
e
(
"获取消息exception:"
+
exception
.
getLocalizedMessage
());
}
});
}
private
void
UpdateFromLocal
()
{
try
{
Map
<
String
,
Object
>
map
=
message
.
getLocalExtension
();
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
;
Integer
posi
=
(
Integer
)
position
;
if
(
b
)
{
//不可点击
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
(
multipleAnswers
.
size
()
>
0
)
{
confirm_multiple_choice
.
setEnabled
(
true
);
confirm_multiple_choice
.
setBackground
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_18dp_1da1f2
));
confirm_multiple_choice
.
setText
(
"确定("
+
multipleAnswers
.
size
()
+
")"
);
}
else
{
confirm_multiple_choice
.
setEnabled
(
false
);
confirm_multiple_choice
.
setBackground
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
im_background_18dp_ebebeb
));
}
}
}
else
{
//可点击
}
}
catch
(
Exception
e
)
{
LogUtil
.
e
(
"aaaaa"
+
e
.
getLocalizedMessage
());
}
}
private
void
UpdateFromLocalExtention
()
{
try
{
Map
<
String
,
Object
>
mapMessage
=
new
HashMap
<>();
if
(
mapMessageFromCustom
!=
null
)
{
mapMessage
=
mapMessageFromCustom
;
if
(
mapMessageFromCustom
!=
null
)
{
mapMessage
=
mapMessageFromCustom
;
}
if
(
mapMessage
!=
null
)
{
Object
questionPaperId
=
mapMessage
.
get
(
customAttachLingxiWhichQuestion
.
id
+
customAttachLingxiWhichQuestion
.
examId
);
Object
questionPaperId
=
mapMessage
.
get
(
customAttachLingxiWhichQuestion
.
id
+
customAttachLingxiWhichQuestion
.
examId
);
if
(
questionPaperId
!=
null
)
{
boolean
b
=
(
boolean
)
questionPaperId
;
if
(
b
)
{
//隐藏回答的信息
recycleviewMultipleChoice
.
setVisibility
(
View
.
GONE
);
confirm_multiple_choice
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
recycleviewMultipleChoice
.
setVisibility
(
View
.
VISIBLE
);
confirm_multiple_choice
.
setVisibility
(
View
.
VISIBLE
);
}
}
else
{
if
(
singleOrMultipletype
.
contains
(
"radio"
)){
}
else
{
if
(
singleOrMultipletype
.
contains
(
"radio"
))
{
recycleviewMultipleChoice
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
recycleviewMultipleChoice
.
setVisibility
(
View
.
VISIBLE
);
confirm_multiple_choice
.
setVisibility
(
View
.
VISIBLE
);
}
...
...
@@ -181,16 +231,16 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
private
void
initMultipleChoice
()
{
if
(
singleOrMultipletype
.
contains
(
"radio"
)){
if
(
singleOrMultipletype
.
contains
(
"radio"
))
{
confirm_multiple_choice
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
confirm_multiple_choice
.
setVisibility
(
View
.
VISIBLE
);
}
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
,
false
));
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
,
false
));
});
multiple_choice_title
.
setText
(
customAttachLingxiWhichQuestion
.
name
);
adapterLingxiMultipleChoice
=
new
AdapterLingxiMultipleChoice
();
...
...
@@ -205,7 +255,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
/*
* 用户回答问题接口
* */
...
...
@@ -226,7 +275,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
public
void
onMultipleItemClick
(
@NotNull
QuestionItemBean
string
,
int
position
)
{
if
(
singleOrMultipletype
.
contains
(
"radio"
))
{
if
(
singleOrMultipletype
.
contains
(
"radio"
))
{
/*
* 单选题:分其他选项和非其他选项
* 其他选项,唤起输入框
...
...
@@ -235,8 +284,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++)
{
if
(
questionList
.
get
(
i
).
isSelected
())
{
if
(
i
==
position
)
{
if
(
questionList
.
get
(
i
).
getName
().
contains
(
"其他"
)){
isClickable
=
true
;
if
(
questionList
.
get
(
i
).
getName
().
contains
(
"其他"
))
{
questionList
.
get
(
i
).
setSelected
(
false
);
selectedStr
.
remove
(
questionList
.
get
(
i
).
getName
());
}
...
...
@@ -245,9 +293,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
i
==
position
)
{
questionList
.
get
(
i
).
setSelected
(
true
);
selectedStr
.
add
(
questionList
.
get
(
i
).
getName
());
}
else
{
}
else
{
questionList
.
get
(
i
).
setSelected
(
false
);
if
(
questionList
.
get
(
i
).
getName
().
contains
(
"其他"
))
{
if
(
questionList
.
get
(
i
).
getName
().
contains
(
"其他"
))
{
selectedStr
.
remove
(
questionList
.
get
(
i
).
getName
());
}
}
...
...
@@ -256,7 +304,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++)
{
if
(
questionList
.
get
(
i
).
isSelected
())
{
if
(
questionList
.
get
(
i
).
isSelected
())
{
answersItems
.
clear
();
answersItems
.
add
(
new
AnswersItem
(
questionList
.
get
(
position
).
getId
(),
questionList
.
get
(
position
).
getName
(),
""
,
questionList
.
get
(
position
).
getRelates
()));
...
...
@@ -268,28 +316,27 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
stringBuffer
.
append
(
"、"
).
append
(
selectedStr
.
get
(
i
));
}
isOthers
=
questionList
.
get
(
position
).
getName
().
contains
(
"其他"
);
if
(!
isOthers
){
isClickable
=
false
;
if
(!
isOthers
)
{
//请求接口发送所选题目
answerLingxiQuestion
(
examId
,
questionPaperId
,
ImIn
.
INSTANCE
.
getUserInfo
().
getUid
().
toString
(),
questionId
,
answersItems
);
//更新本地消息
updateLocalMsg
(
position
,
null
);
updateLocalMsg
(
position
,
null
);
//发通知取消隐藏输入框表情等符号
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
,
true
));
}
else
{
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
,
true
));
}
else
{
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
,
false
));
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
,
false
));
}
}
else
{
}
else
{
//多选发送消息
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++)
{
if
(
questionList
.
get
(
i
).
isSelected
())
{
if
(
i
==
position
)
{
questionList
.
get
(
i
).
setSelected
(
false
);
selectedStr
.
remove
(
questionList
.
get
(
i
).
getName
());
for
(
int
j
=
0
;
j
<
answersItems
.
size
();
j
++)
{
if
(
questionList
.
get
(
i
).
getName
()==
answersItems
.
get
(
j
).
getName
())
{
for
(
int
j
=
0
;
j
<
answersItems
.
size
();
j
++)
{
if
(
questionList
.
get
(
i
).
getName
()
==
answersItems
.
get
(
j
).
getName
())
{
answersItems
.
remove
(
j
);
break
;
}
...
...
@@ -323,24 +370,30 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
isOthers
=
questionList
.
get
(
position
).
getName
().
contains
(
"其他"
);
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
,
false
));
questionId
,
answersItems
,
message
.
getFromAccount
()),
false
,
false
));
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
answersItemsMap
.
clear
();
for
(
int
i
=
0
;
i
<
answersItems
.
size
();
i
++)
{
if
(!
answersItemsMap
.
contains
(
answersItems
.
get
(
i
).
getName
()))
{
answersItemsMap
.
add
(
i
,
answersItems
.
get
(
i
).
getName
());
}
}
updateLocalMsg
(
null
,
answersItemsMap
);
}
}
private
void
updateLocalMsg
(
Integer
position
,
ArrayList
<
String
>
selectedPosition
)
{
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
)
{
if
(
position
!=
null
)
{
map
.
put
(
"position"
,
position
);
}
if
(
selectedPosition
!=
null
)
{
if
(
selectedPosition
!=
null
)
{
map
.
put
(
"multiple"
,
selectedPosition
);
}
message
.
setLocalExtension
(
null
);
message
.
setLocalExtension
(
map
);
NIMClient
.
getService
(
MsgService
.
class
).
updateIMMessage
(
message
);
//通知ui刷新
...
...
m-im/src/main/res/layout/im_nim_lingxi_which_question.xml
deleted
100644 → 0
View file @
8bccedf0
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/im_custom_message_round_white_6dp_bg"
android:paddingLeft=
"@dimen/platform_dp_12"
android:paddingRight=
"@dimen/platform_dp_3"
android:paddingTop=
"@dimen/platform_dp_12"
>
<TextView
android:id=
"@+id/which_question_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxWidth=
"263dp"
android:textColor=
"@color/im_color_242424"
android:textSize=
"@dimen/im_text_size_17"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"您想要咨询下类哪类问?"
android:layout_marginBottom=
"@dimen/platform_dp_16"
app:layout_constraintBottom_toTopOf=
"@id/which_question_rv"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/which_question_rv"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"@dimen/dp_4"
android:orientation=
"vertical"
app:layoutManager=
"androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"@id/which_question_title"
app:layout_constraintTop_toBottomOf=
"@id/which_question_title"
app:spanCount=
"2"
tools:itemCount=
"6"
tools:listitem=
"@layout/im_lingxi_which_question_item"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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