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
69d2343d
Commit
69d2343d
authored
Jun 23, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:im-灵犀2.0-多选逻辑
parent
f0294026
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
19 deletions
+33
-19
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+23
-18
AdapterLingxiWhichQuestion.kt
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
+10
-1
No files found.
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
69d2343d
...
...
@@ -26,8 +26,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private
AdapterLingxiMultipleChoice
adapterLingxiMultipleChoice
;
ArrayList
<
QuestionItemBean
>
questionList
=
new
ArrayList
<
QuestionItemBean
>();
Integer
maxItemSize
=
5
;
Boolean
isSingleChoice
=
true
;
Boolean
isSingleChoice
=
false
;
CustomAttachLingxiWhichQuestion
customAttachLingxiWhichQuestion
;
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
...
...
@@ -38,8 +37,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
:
//您是先生还是女生
...
...
@@ -61,29 +60,35 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
customAttachLingxiWhichQuestion
=
((
CustomAttachLingxiWhichQuestion
)
message
.
getAttachment
());
//您想要咨询下列哪类的问题?(单选)
//
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
adapterLingxiWhichQuestion
=
new
AdapterLingxiWhichQuestion
();
for
(
int
i
=
0
;
i
<
8
;
i
++){
questionList
.
add
(
new
QuestionItemBean
(
"1"
,
"婚姻情感试"
,
false
));
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
);
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
if
(
questionList
.
get
(
i
).
getName
().
length
()>
5
){
isSingleChoice
=
true
;
break
;
}
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
adapterLingxiWhichQuestion
.
setItemListener
(
this
);
GridLayoutManager
gridLayoutManager
=
new
GridLayoutManager
(
context
,
2
);
//当list中字段大于6个显示单行,否则显示双行
gridLayoutManager
.
setSpanCount
(
maxItemSize
>
6
?
1
:
2
);
gridLayoutManager
.
setSpanCount
(
isSingleChoice
?
1
:
2
);
gridLayoutManager
.
setOrientation
(
GridLayoutManager
.
VERTICAL
);
recycleviewWhichQuestion
.
setLayoutManager
(
gridLayoutManager
);
recycleviewWhichQuestion
.
setAdapter
(
adapterLingxiWhichQuestion
);
//请问是发生了什么事情导致的呢?(多选)
adapterLingxiMultipleChoice
=
new
AdapterLingxiMultipleChoice
();
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
adapterLingxiMultipleChoice
.
setItemListener
(
this
);
GridLayoutManager
multipleChoiceManager
=
new
GridLayoutManager
(
context
,
2
);
//当list中字段大于6个显示单行,否则显示双行
multipleChoiceManager
.
setSpanCount
(
maxItemSize
>
6
?
1
:
2
);
multipleChoiceManager
.
setOrientation
(
GridLayoutManager
.
VERTICAL
);
recycleviewMultipleChoice
.
setLayoutManager
(
multipleChoiceManager
);
recycleviewMultipleChoice
.
setAdapter
(
adapterLingxiMultipleChoice
);
//
//请问是发生了什么事情导致的呢?(多选)
//
adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
//
adapterLingxiMultipleChoice.setTagData(questionList);
//
adapterLingxiMultipleChoice.setItemListener(this);
//
GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2);
//
//当list中字段大于6个显示单行,否则显示双行
//
multipleChoiceManager.setSpanCount(maxItemSize > 6 ? 1 : 2);
//
multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL);
//
recycleviewMultipleChoice.setLayoutManager(multipleChoiceManager);
//
recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice);
}
...
...
@@ -92,7 +97,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
questionList
.
get
(
i
).
setSelected
(
i
==
position
);
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
);
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
}
@Override
...
...
m-im/src/main/java/com/yidianling/im/session/viewholder/adapter/AdapterLingxiWhichQuestion.kt
View file @
69d2343d
...
...
@@ -6,9 +6,12 @@ import android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
com.ydl.ydlcommon.data.http.RxUtils
import
com.yidianling.common.tools.RxImageTool
import
com.yidianling.im.R
import
com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
import
com.yidianling.im.session.viewholder.bean.QuestionItemBean
import
kotlin.properties.Delegates
/**
* @author huozhiliang
...
...
@@ -19,6 +22,8 @@ import com.yidianling.im.session.viewholder.bean.QuestionItemBean
*/
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
)
:
...
...
@@ -53,9 +58,13 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti
onItemClickListener
?.
onItemClick
(
tagList
[
position
],
position
)
}
if
(
isSingleOrMultiple
){
holder
.
tvWhichQuestion
.
setPadding
(
RxImageTool
.
dip2px
(
62f
),
RxImageTool
.
dp2px
(
8f
),
RxImageTool
.
dip2px
(
62f
),
RxImageTool
.
dp2px
(
8f
))
}
}
fun
setTagData
(
data
:
List
<
QuestionItemBean
>)
{
fun
setTagData
(
data
:
List
<
QuestionItemBean
>
,
isSingleOrMultiple
:
Boolean
)
{
tagList
=
data
this
.
isSingleOrMultiple
=
isSingleOrMultiple
notifyDataSetChanged
()
}
interface
OnQuestionlItemClickListener
{
...
...
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