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
a358fcc2
Commit
a358fcc2
authored
Jun 23, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:im-灵犀2.0-多选逻辑
parent
69d2343d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
28 deletions
+92
-28
MultipleSelectedEvent.kt
m-im/src/main/java/com/yidianling/im/event/MultipleSelectedEvent.kt
+6
-0
MsgViewHolderLingxiWhichQuestion.java
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
+53
-22
YDLMessageFragment.java
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
+17
-5
im_nim_lingxi_multiple_choice.xml
m-im/src/main/res/layout/im_nim_lingxi_multiple_choice.xml
+1
-1
im_ydl_nim_message_fragment.xml
m-im/src/main/res_uikit/layout/im_ydl_nim_message_fragment.xml
+15
-0
No files found.
m-im/src/main/java/com/yidianling/im/event/MultipleSelectedEvent.kt
0 → 100644
View file @
a358fcc2
package
com.yidianling.im.event
public
class
MultipleSelectedEvent
(
val
strSelected
:
String
)
\ No newline at end of file
m-im/src/main/java/com/yidianling/im/session/viewholder/MsgViewHolderLingxiWhichQuestion.java
View file @
a358fcc2
package
com
.
yidianling
.
im
.
session
.
viewholder
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
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.CustomAttachmentOrderStatus
;
import
com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice
;
...
...
@@ -19,15 +23,20 @@ import org.jetbrains.annotations.NotNull;
import
java.util.ArrayList
;
import
de.greenrobot.event.EventBus
;
public
class
MsgViewHolderLingxiWhichQuestion
extends
MsgViewHolderBase
implements
AdapterLingxiWhichQuestion
.
OnQuestionlItemClickListener
,
AdapterLingxiMultipleChoice
.
OnMultiplelItemClickListener
{
private
RecyclerView
recycleviewWhichQuestion
;
private
RecyclerView
recycleviewMultipleChoice
;
private
TextView
confirm_multiple_choice
;
private
AdapterLingxiWhichQuestion
adapterLingxiWhichQuestion
;
private
AdapterLingxiMultipleChoice
adapterLingxiMultipleChoice
;
ArrayList
<
QuestionItemBean
>
questionList
=
new
ArrayList
<
QuestionItemBean
>();
Boolean
isSingleChoice
=
false
;
CustomAttachLingxiWhichQuestion
customAttachLingxiWhichQuestion
;
private
StringBuffer
stringBuffer
=
new
StringBuffer
(
"已选:"
);
ArrayList
<
String
>
selectedStr
=
new
ArrayList
<
String
>();
public
MsgViewHolderLingxiWhichQuestion
(
BaseMultiItemFetchLoadAdapter
adapter
)
{
super
(
adapter
);
}
...
...
@@ -37,8 +46,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
:
//您是先生还是女生
...
...
@@ -52,6 +61,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
protected
void
inflateContentView
()
{
recycleviewWhichQuestion
=
findViewById
(
R
.
id
.
which_question_rv
);
recycleviewMultipleChoice
=
findViewById
(
R
.
id
.
multiple_question_rv
);
confirm_multiple_choice
=
findViewById
(
R
.
id
.
confirm_multiple_choice
);
}
...
...
@@ -62,7 +72,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
adapterLingxiWhichQuestion
=
new
AdapterLingxiWhichQuestion
();
for
(
int
i
=
0
;
i
<
8
;
i
++){
questionList
.
add
(
new
QuestionItemBean
(
"1"
,
"婚姻情感试"
,
false
));
questionList
.
add
(
new
QuestionItemBean
(
"1"
,
"婚姻情感试"
+
i
,
false
));
}
for
(
int
i
=
0
;
i
<
questionList
.
size
();
i
++){
if
(
questionList
.
get
(
i
).
getName
().
length
()>
5
){
...
...
@@ -70,25 +80,36 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
break
;
}
}
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
adapterLingxiWhichQuestion
.
setItemListener
(
this
);
GridLayoutManager
gridLayoutManager
=
new
GridLayoutManager
(
context
,
2
);
//当list中字段大于6个显示单行,否则显示双行
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);
switch
(
Integer
.
parseInt
(
customAttachLingxiWhichQuestion
.
selectType
)){
case
1
:
//您想要咨询下列哪类的问题?(单选)
adapterLingxiWhichQuestion
.
setTagData
(
questionList
,
isSingleChoice
);
adapterLingxiWhichQuestion
.
setItemListener
(
this
);
GridLayoutManager
gridLayoutManager
=
new
GridLayoutManager
(
context
,
2
);
//当list中字段大于6个显示单行,否则显示双行
gridLayoutManager
.
setSpanCount
(
isSingleChoice
?
1
:
2
);
gridLayoutManager
.
setOrientation
(
GridLayoutManager
.
VERTICAL
);
recycleviewWhichQuestion
.
setLayoutManager
(
gridLayoutManager
);
recycleviewWhichQuestion
.
setAdapter
(
adapterLingxiWhichQuestion
);
break
;
case
2
:
//请问是发生了什么事情导致的呢?(多选)
// //请问是发生了什么事情导致的呢?(多选)
adapterLingxiMultipleChoice
=
new
AdapterLingxiMultipleChoice
();
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
adapterLingxiMultipleChoice
.
setItemListener
(
this
);
GridLayoutManager
multipleChoiceManager
=
new
GridLayoutManager
(
context
,
2
);
//当list中字段大于6个显示单行,否则显示双行
multipleChoiceManager
.
setSpanCount
(
isSingleChoice
?
1
:
2
);
multipleChoiceManager
.
setOrientation
(
GridLayoutManager
.
VERTICAL
);
recycleviewMultipleChoice
.
setLayoutManager
(
multipleChoiceManager
);
recycleviewMultipleChoice
.
setAdapter
(
adapterLingxiMultipleChoice
);
break
;
case
3
:
//您是先生还是女生
break
;
default
:
break
;
}
}
...
...
@@ -107,13 +128,23 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if
(
questionList
.
get
(
i
).
isSelected
()){
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
false
);
selectedStr
.
remove
(
questionList
.
get
(
i
).
getName
());
}
}
else
{
if
(
i
==
position
){
questionList
.
get
(
i
).
setSelected
(
true
);
selectedStr
.
add
(
questionList
.
get
(
i
).
getName
());
}
}
}
confirm_multiple_choice
.
setText
(
selectedStr
.
size
());
stringBuffer
.
delete
(
2
,
stringBuffer
.
length
());
for
(
int
i
=
0
;
i
<
selectedStr
.
size
();
i
++){
stringBuffer
.
append
(
"#"
).
append
(
selectedStr
.
get
(
i
));
}
EventBus
.
getDefault
().
post
(
new
MultipleSelectedEvent
(
stringBuffer
.
toString
()));
adapterLingxiMultipleChoice
.
setTagData
(
questionList
);
}
}
m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
View file @
a358fcc2
...
...
@@ -22,6 +22,7 @@ import android.widget.LinearLayout;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.recyclerview.widget.RecyclerView
;
...
...
@@ -57,6 +58,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.event.MultipleSelectedEvent
;
import
com.yidianling.im.helper.IMChatUtil
;
import
com.yidianling.im.router.ImIn
;
import
com.yidianling.nimbase.api.UIKitOptions
;
...
...
@@ -102,6 +104,7 @@ import java.util.Calendar;
import
java.util.List
;
import
java.util.Map
;
import
de.greenrobot.event.EventBus
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.schedulers.Schedulers
;
...
...
@@ -167,7 +170,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private
RelativeLayout
rl_common_question_enter
;
private
FrameLayout
fl_question_content
;
private
List
<
CommonQuestionBean
>
commonQuestionBeanList
;
private
TextView
question_multiple
;
private
LinearLayout
comment_banner_view_ll
;
private
TextView
tv_all_comment_desc
;
private
ImageView
tv_all_comment_go
;
...
...
@@ -260,8 +263,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
//和助理私聊时的常用语逻辑
rl_common_question_enter
=
rootView
.
findViewById
(
R
.
id
.
rl_common_question
);
fl_question_content
=
rootView
.
findViewById
(
R
.
id
.
fl_question_content
);
rl_common_question_enter
.
setVisibility
(
ActionHandlerStorage
.
getL
(
sessionId
)
!=
null
&&
ActionHandlerStorage
.
getL
(
sessionId
).
getUserType
()
==
3
?
View
.
VISIBLE
:
View
.
GONE
);
question_multiple
=
rootView
.
findViewById
(
R
.
id
.
question_multiple
);
//做灵犀2.0 去掉常用语逻辑
//rl_common_question_enter.setVisibility(ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 3 ? View.VISIBLE : View.GONE);
if
(
ActionHandlerStorage
.
getL
(
sessionId
).
getUserType
()
!=
2
)
{
if
(
null
!=
getActivity
()
&&
null
!=
rela_zixun
)
{
rela_zixun
.
setVisibility
(
View
.
GONE
);
...
...
@@ -287,6 +291,12 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
}
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
EventBus
.
getDefault
().
register
(
this
);
}
private
void
initView
()
{
if
(
ActionHandlerStorage
.
getL
(
sessionId
)
!=
null
&&
ActionHandlerStorage
.
getL
(
sessionId
).
getUserType
()
==
3
)
{
rl_common_question_enter
.
setOnClickListener
(
v
->
{
...
...
@@ -1047,7 +1057,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
@Override
public
void
onDestroy
()
{
comment_banner_view
.
onDestory
();
EventBus
.
getDefault
().
unregister
(
this
);
super
.
onDestroy
();
messageListPanel
.
onDestroy
();
registerObservers
(
false
);
...
...
@@ -1058,7 +1068,9 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
aitManager
.
reset
();
}
}
public
void
onEvent
(
MultipleSelectedEvent
event
){
question_multiple
.
setText
(
event
.
getStrSelected
());
}
public
boolean
onBackPressed
()
{
return
inputPanel
.
collapse
(
true
)
||
messageListPanel
.
onBackPressed
()
||
openOrCloseCommonQuestionLayout
(
false
);
}
...
...
m-im/src/main/res/layout/im_nim_lingxi_multiple_choice.xml
View file @
a358fcc2
...
...
@@ -36,7 +36,7 @@
android:layout_width=
"110dp"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@id/multiple_question_rv"
android:text=
"确定(
2
)"
android:text=
"确定(
0
)"
android:layout_marginTop=
"@dimen/platform_dp_24"
android:textSize=
"@dimen/im_text_size_15"
app:layout_constraintEnd_toEndOf=
"@id/multiple_question_rv"
...
...
m-im/src/main/res_uikit/layout/im_ydl_nim_message_fragment.xml
View file @
a358fcc2
...
...
@@ -575,6 +575,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"42dp"
android:layout_gravity=
"bottom"
android:visibility=
"invisible"
android:background=
"@drawable/im_background_chat_common_question"
android:paddingRight=
"13dp"
>
...
...
@@ -589,6 +590,20 @@
android:textStyle=
"bold"
/>
</RelativeLayout>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"@dimen/im_sp_14"
android:textColor=
"@color/im_color_242424"
android:layout_gravity=
"bottom"
android:id=
"@+id/question_multiple"
tools:text=
"已选:#工作压力 #生活压力#其他"
android:layout_marginStart=
"@dimen/platform_dp_12"
android:layout_marginEnd=
"@dimen/platform_dp_12"
android:layout_marginBottom=
"@dimen/platform_dp_8"
>
</TextView>
</FrameLayout>
<FrameLayout
...
...
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