Commit 2d620ac1 by 霍志良

feat:im-灵犀2.0-用户显示灵犀的正在输入中

parent e9e55060
......@@ -2,5 +2,9 @@ package com.yidianling.im.event
public class MultipleSelectedEvent (
val strSelected:String,
var isOthers:Boolean
var othersState:OthersState
)
data class OthersState(
var isOthers:Boolean,
var othersSelect:Boolean
)
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.ydl.ydlcommon.data.http.RxUtils;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.im.R;
import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.event.OthersState;
import com.yidianling.im.http.ImRetrofitApi;
import com.yidianling.im.router.ImIn;
import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion;
......@@ -47,6 +48,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private RecyclerView recycleviewMultipleChoice;
private TextView confirm_multiple_choice;
private TextView which_question_title;
private TextView multiple_choice_title;
private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion;
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
......@@ -57,7 +59,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private StringBuffer stringBuffer=new StringBuffer("已选:");
ArrayList<String> selectedStr=new ArrayList<String>();
private Boolean isClickable=true;
private Boolean isOthers;
//回答试卷接口
private String examId;
private String questionPaperId;
......@@ -94,6 +96,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
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);
multiple_choice_title = findViewById(R.id.multiple_choice_title);
}
......@@ -109,7 +112,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
questionList= (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options;
}
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
which_question_title.setText(customAttachLingxiWhichQuestion.name);
for (int i=0;i<questionList.size();i++){
questionList.get(i).setSelected(false);
if (questionList.get(i).getName().length()>5){
......@@ -122,27 +124,11 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
switch (customAttachLingxiWhichQuestion.type){
case "radio"://您想要咨询下列哪类的问题?(单选)
if (questionList!=null&&questionList.size()!=0){
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);
initSingleChoice();
}
break;
case "check"://请问是发生了什么事情导致的呢?(多选)
// //请问是发生了什么事情导致的呢?(多选)
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);
initMultipleChoice();
break;
case "3"://您是先生还是女生
break;
......@@ -151,6 +137,12 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
}
UpdateFromLocalExtention();
}
private void UpdateFromLocalExtention() {
try {
Map<String, Object> map = message.getLocalExtension();
if (map != null) {
......@@ -175,8 +167,31 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
} catch (Exception e) {
}
}
private void initMultipleChoice() {
multiple_choice_title.setText(customAttachLingxiWhichQuestion.name);
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);
}
private void initSingleChoice() {
which_question_title.setText(customAttachLingxiWhichQuestion.name);
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);
}
@Override
......@@ -236,12 +251,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
for (int i=0;i<selectedStr.size();i++){
stringBuffer.append("#").append(selectedStr.get(i));
}
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),false));
isOthers=questionList.get(position).getName().contains("其他");
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),new OthersState(isOthers,questionList.get(position).isSelected())));
adapterLingxiMultipleChoice.setTagData(questionList);
if (questionList.get(position).getName().contains("其他")){
//唤起输入键盘,隐藏标签、图片等其他布局
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),true));
}
}
private void updateLocalMsg(Integer position) {
//更新本地消息
......
......@@ -220,7 +220,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private String userInfoDialogSourceFrom = "";
private UserInfoDialog userInfoDialog = null;
private boolean isOthers;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
......@@ -1079,9 +1079,22 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
public void onEvent(MultipleSelectedEvent event){
if (event.isOthers()){
if (event.getOthersState().isOthers()){
//用户点击了其他事件
inputPanel.onlyShowTextStart();
if (event.getOthersState().getOthersSelect()){
//其他是选中状态
isOthers=event.getOthersState().getOthersSelect();
rootView.postDelayed(new Runnable() {
@Override
public void run() {
inputPanel.onlyShowTextStart();
}
}, 500);
}else{
//其他是未选中状态
isOthers=event.getOthersState().getOthersSelect();
inputPanel.onlyShowTextEnd();
}
}else{
question_multiple.setText(event.getStrSelected());
}
......
......@@ -144,7 +144,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
private String sendText = "";
private Boolean onlyShowInputTest=false;
private Boolean onlyShowInputTest=false;//灵犀2.0 点击其他的时候隐藏除输入框以外的其他内容
/***设置输入框内容*/
public void setInputContent(String content) {
......@@ -857,6 +857,7 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
* 隐藏所有输入布局
*/
private void hideAllInputLayout(boolean immediately) {
if (hideAllInputLayoutRunnable == null) {
hideAllInputLayoutRunnable = new Runnable() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment