Commit 7a524767 by 霍志良

feat:im-灵犀2.0-其他选项

parent d3d0e5ec
package com.yidianling.im.event package com.yidianling.im.event
import com.yidianling.im.router.ImIn.getUserInfo
import com.yidianling.im.session.viewholder.bean.AnswersItem
public class MultipleSelectedEvent ( public class MultipleSelectedEvent (
val strSelected:String, val strSelected:String?,
var othersState:OthersState var othersState:OthersState?,
var multipleAnswerBean:MultipleAnswerBean?
) )
data class OthersState( data class OthersState(
var isOthers:Boolean, var isOthers:Boolean,
var othersSelect:Boolean var othersSelect:Boolean
)
data class MultipleAnswerBean(
var examId:String,
var questionPaperId:String,
var uid:String,
var questionId:String,
var answersItems:ArrayList<AnswersItem>,
var fromUid:String
) )
\ No newline at end of file
...@@ -5,13 +5,17 @@ import android.widget.TextView; ...@@ -5,13 +5,17 @@ import android.widget.TextView;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachLingxiAnswerQuestion; import com.yidianling.im.session.extension.CustomAttachLingxiAnswerQuestion;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter; import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase; import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
import java.util.ArrayList;
public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase { public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
private TextView answer_question; private TextView answer_question;
CustomAttachLingxiAnswerQuestion customattachLingxiAnswerQuestion; CustomAttachLingxiAnswerQuestion customattachLingxiAnswerQuestion;
private ArrayList<QuestionItemBean> itemBeans;
private StringBuffer sb;
public MsgViewHolderLingxiAnswerQuestion(BaseMultiItemFetchLoadAdapter adapter) { public MsgViewHolderLingxiAnswerQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter); super(adapter);
} }
...@@ -36,7 +40,21 @@ public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase { ...@@ -36,7 +40,21 @@ public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
@Override @Override
protected void bindContentView() { protected void bindContentView() {
customattachLingxiAnswerQuestion = ((CustomAttachLingxiAnswerQuestion) message.getAttachment()); customattachLingxiAnswerQuestion = ((CustomAttachLingxiAnswerQuestion) message.getAttachment());
itemBeans=customattachLingxiAnswerQuestion.answers;
answer_question.setText(customattachLingxiAnswerQuestion.answers.get(0).getName()); sb=new StringBuffer();
for (int i=0;i<itemBeans.size();i++){
if (i==(itemBeans.size()-1)&&itemBeans.get(i).getName().contains("其他")){
sb.append("#"+itemBeans.get(i).getName()+"\r\n ").append(itemBeans.get(i).getOther());
}else{
sb.append("#"+itemBeans.get(i).getName()+" ");
}
}
if (itemBeans.size()==1){
answer_question.setText(itemBeans.get(0).getName());
}else{
answer_question.setText(sb.toString());
}
} }
} }
...@@ -19,6 +19,7 @@ import com.ydl.ydlcommon.data.http.RxUtils; ...@@ -19,6 +19,7 @@ import com.ydl.ydlcommon.data.http.RxUtils;
import com.yidianling.common.tools.LogUtil; import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.im.event.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent; import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.event.OthersState; import com.yidianling.im.event.OthersState;
import com.yidianling.im.http.ImRetrofitApi; import com.yidianling.im.http.ImRetrofitApi;
...@@ -58,38 +59,39 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -58,38 +59,39 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice; private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>(); ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>();
Boolean isSingleChoice=false; Boolean isSingleChoice = false;
CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion; CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion;
private StringBuffer stringBuffer=new StringBuffer("已选:"); private StringBuffer stringBuffer = new StringBuffer("已选:");
ArrayList<String> selectedStr=new ArrayList<String>(); ArrayList<String> selectedStr = new ArrayList<String>();
private Boolean isClickable=true; private Boolean isClickable = true;
private Boolean isOthers; private Boolean isOthers;
//回答试卷接口 //回答试卷接口
private String examId; private String examId;
private String questionPaperId; private String questionPaperId;
private String questionId; private String questionId;
private ArrayList<AnswersItem> answersItems=new ArrayList<>(); private ArrayList<AnswersItem> answersItems = new ArrayList<>();
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) { public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter); super(adapter);
} }
@Override @Override
protected int getContentResId() { protected int getContentResId() {
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment()); customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
if (customAttachLingxiWhichQuestion.type!=null){ if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type){ switch (customAttachLingxiWhichQuestion.type) {
case "radio"://您想要咨询下列哪类的问题?(单选) case "radio"://您想要咨询下列哪类的问题?(单选)
return R.layout.im_nim_lingxi_which_question; return R.layout.im_nim_lingxi_which_question;
case "check"://请问是发生了什么事情导致的呢?(多选) case "check"://请问是发生了什么事情导致的呢?(多选)
return R.layout.im_nim_lingxi_multiple_choice; return R.layout.im_nim_lingxi_multiple_choice;
case "3"://您是先生还是女生 case "3"://您是先生还是女生
return R.layout.im_nim_lingxi_men_female; return R.layout.im_nim_lingxi_men_female;
default: default:
return R.layout.im_nim_lingxi_which_question; return R.layout.im_nim_lingxi_which_question;
} }
}else{ } else {
return R.layout.im_nim_lingxi_which_question; return R.layout.im_nim_lingxi_which_question;
} }
} }
...@@ -106,34 +108,32 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -106,34 +108,32 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override @Override
protected void bindContentView() { protected void bindContentView() {
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment()); customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
examId=customAttachLingxiWhichQuestion.examId; examId = customAttachLingxiWhichQuestion.examId;
questionPaperId=customAttachLingxiWhichQuestion.questionPaperId; questionPaperId = customAttachLingxiWhichQuestion.questionPaperId;
questionId=customAttachLingxiWhichQuestion.id; questionId = customAttachLingxiWhichQuestion.id;
//您想要咨询下列哪类的问题?(单选) //您想要咨询下列哪类的问题?(单选)
if (customAttachLingxiWhichQuestion.options!=null){ if (customAttachLingxiWhichQuestion.options != null) {
questionList= (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options; questionList = (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options;
} }
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion(); adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
for (int i=0;i<questionList.size();i++){ for (int i = 0; i < questionList.size(); i++) {
questionList.get(i).setSelected(false); questionList.get(i).setSelected(false);
if (questionList.get(i).getName().length()>5){ if (questionList.get(i).getName().length() > 5) {
isSingleChoice=true; isSingleChoice = true;
break; break;
} }
} }
if (customAttachLingxiWhichQuestion.type!=null){ if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type){ switch (customAttachLingxiWhichQuestion.type) {
case "radio"://您想要咨询下列哪类的问题?(单选) case "radio"://您想要咨询下列哪类的问题?(单选)
if (questionList!=null&&questionList.size()!=0){ if (questionList != null && questionList.size() != 0) {
initSingleChoice(); initSingleChoice();
} }
break; break;
case "check"://请问是发生了什么事情导致的呢?(多选) case "check"://请问是发生了什么事情导致的呢?(多选)
initMultipleChoice(); initMultipleChoice();
break; break;
case "3"://您是先生还是女生
break;
default: default:
break; break;
} }
...@@ -153,18 +153,18 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -153,18 +153,18 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if (obj != null) { if (obj != null) {
boolean b = (boolean) obj; boolean b = (boolean) obj;
Integer posi=(Integer) position; Integer posi = (Integer) position;
if (b) { if (b) {
//不可点击 //不可点击
isClickable=false; isClickable = false;
questionList.get(posi).setSelected(true); questionList.get(posi).setSelected(true);
} }
} else { } else {
//可点击 //可点击
} }
} else { } else {
//可点击 //可点击
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -173,8 +173,10 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -173,8 +173,10 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private void initMultipleChoice() { private void initMultipleChoice() {
confirm_multiple_choice.setOnClickListener(view -> { confirm_multiple_choice.setOnClickListener(view -> {
//请求接口发送所选题目 //请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。
answerLingxiQuestion(examId,questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),questionId,answersItems); EventBus.getDefault().post(new MultipleSelectedEvent(null, null,
new MultipleAnswerBean(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),
questionId, answersItems,message.getFromAccount())));
}); });
multiple_choice_title.setText(customAttachLingxiWhichQuestion.name); multiple_choice_title.setText(customAttachLingxiWhichQuestion.name);
adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice(); adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
...@@ -182,7 +184,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -182,7 +184,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
adapterLingxiMultipleChoice.setItemListener(this); adapterLingxiMultipleChoice.setItemListener(this);
GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2); GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2);
//当list中字段大于6个显示单行,否则显示双行 //当list中字段大于6个显示单行,否则显示双行
multipleChoiceManager.setSpanCount( isSingleChoice ? 1 : 2); multipleChoiceManager.setSpanCount(isSingleChoice ? 1 : 2);
multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL); multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL);
recycleviewMultipleChoice.setLayoutManager(multipleChoiceManager); recycleviewMultipleChoice.setLayoutManager(multipleChoiceManager);
recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice); recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice);
...@@ -190,7 +192,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -190,7 +192,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private void initSingleChoice() { private void initSingleChoice() {
which_question_title.setText(customAttachLingxiWhichQuestion.name); which_question_title.setText(customAttachLingxiWhichQuestion.name);
adapterLingxiWhichQuestion.setTagData(questionList,isSingleChoice); adapterLingxiWhichQuestion.setTagData(questionList, isSingleChoice);
adapterLingxiWhichQuestion.setItemListener(this); adapterLingxiWhichQuestion.setItemListener(this);
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2); GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2);
//当list中字段大于6个显示单行,否则显示双行 //当list中字段大于6个显示单行,否则显示双行
...@@ -202,16 +204,16 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -202,16 +204,16 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override @Override
public void onItemClick(@NotNull QuestionItemBean itemBean, int position) { public void onItemClick(@NotNull QuestionItemBean itemBean, int position) {
if (isClickable){ if (isClickable) {
for (int i=0;i<questionList.size();i++){ for (int i = 0; i < questionList.size(); i++) {
questionList.get(i).setSelected(i==position); questionList.get(i).setSelected(i == position);
} }
adapterLingxiWhichQuestion.setTagData(questionList,isSingleChoice); adapterLingxiWhichQuestion.setTagData(questionList, isSingleChoice);
isClickable=false; isClickable = false;
answersItems.add(new AnswersItem(questionList.get(position).getId(), answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(),"其他",questionList.get(position).getRelates())); questionList.get(position).getName(), "", questionList.get(position).getRelates()));
//请求接口发送所选题目 //请求接口发送所选题目
answerLingxiQuestion(examId,questionPaperId, ImIn.INSTANCE.getUserInfo().getUid().toString(),questionId,answersItems); answerLingxiQuestion(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid().toString(), questionId, answersItems);
//更新本地消息 //更新本地消息
updateLocalMsg(position); updateLocalMsg(position);
...@@ -221,15 +223,15 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -221,15 +223,15 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
/* /*
* 用户回答问题接口 * 用户回答问题接口
* */ * */
private void answerLingxiQuestion(String examID , String questionPaperId, String uid, String questionId, ArrayList<AnswersItem> answersItems) { private void answerLingxiQuestion(String examID, String questionPaperId, String uid, String questionId, ArrayList<AnswersItem> answersItems) {
String str = new Gson().toJson(new LingxiAnswerBean(new AnswerBean(examID,questionPaperId,uid,questionId,answersItems),message.getFromAccount(),"56",uid)); String str = new Gson().toJson(new LingxiAnswerBean(new AnswerBean(examID, questionPaperId, uid, questionId, answersItems), message.getFromAccount(), "56", uid));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str); RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str);
Disposable subscribe = ImRetrofitApi.Companion.getImRetrofitApi().lingxiAnswerQuestion(body) Disposable subscribe = ImRetrofitApi.Companion.getImRetrofitApi().lingxiAnswerQuestion(body)
.compose(RxUtils.INSTANCE.resultJavaData()) .compose(RxUtils.INSTANCE.resultJavaData())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> { .subscribe(it -> {
LogUtil.e("answerQuestion"+it.toString()); LogUtil.e("answerQuestion" + it.toString());
}, throwable -> }, throwable ->
LogUtil.e(throwable.getMessage()) LogUtil.e(throwable.getMessage())
); );
...@@ -239,46 +241,46 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -239,46 +241,46 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override @Override
public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) { public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) {
//多选发送消息 //多选发送消息
for (int i=0;i<questionList.size();i++){ for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()){ if (questionList.get(i).isSelected()) {
if (i==position){ if (i == position) {
questionList.get(i).setSelected(false); questionList.get(i).setSelected(false);
selectedStr.remove(questionList.get(i).getName()); selectedStr.remove(questionList.get(i).getName());
answersItems.remove(position); answersItems.remove(position);
} }
}else{ } else {
if (i==position){ if (i == position) {
questionList.get(i).setSelected(true); questionList.get(i).setSelected(true);
selectedStr.add(questionList.get(i).getName()); selectedStr.add(questionList.get(i).getName());
answersItems.add(new AnswersItem(questionList.get(position).getId(), answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(),"其他",questionList.get(position).getRelates())); questionList.get(position).getName(), "", questionList.get(position).getRelates()));
} }
} }
} }
confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size())); confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size()));
if (selectedStr.size()>0){ if (selectedStr.size() > 0) {
confirm_multiple_choice.setEnabled(true); confirm_multiple_choice.setEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2)); confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2));
} }
}else{ } else {
confirm_multiple_choice.setEnabled(false); confirm_multiple_choice.setEnabled(false);
confirm_multiple_choice.setText("确定"); confirm_multiple_choice.setText("确定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getDrawable(R.drawable.im_background_18dp_ebebeb)); confirm_multiple_choice.setBackground(context.getDrawable(R.drawable.im_background_18dp_ebebeb));
} }
} }
stringBuffer.delete(2,stringBuffer.length()); stringBuffer.delete(2, stringBuffer.length());
for (int i=0;i<selectedStr.size();i++){ for (int i = 0; i < selectedStr.size(); i++) {
stringBuffer.append("#").append(selectedStr.get(i)); stringBuffer.append("#").append(selectedStr.get(i));
} }
isOthers=questionList.get(position).getName().contains("其他"); isOthers = questionList.get(position).getName().contains("其他");
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(),new OthersState(isOthers,questionList.get(position).isSelected()))); EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(), new OthersState(isOthers, questionList.get(position).isSelected()), null));
adapterLingxiMultipleChoice.setTagData(questionList); adapterLingxiMultipleChoice.setTagData(questionList);
} }
private void updateLocalMsg(Integer position) { private void updateLocalMsg(Integer position) {
//更新本地消息 //更新本地消息
Map<String, Object> map = message.getLocalExtension(); Map<String, Object> map = message.getLocalExtension();
...@@ -298,16 +300,16 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -298,16 +300,16 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
for (IMMessage msg : param) { for (IMMessage msg : param) {
MsgAttachment attachment = msg.getAttachment(); MsgAttachment attachment = msg.getAttachment();
if (attachment instanceof CustomAttachLingxiWhichQuestion) { if (attachment instanceof CustomAttachLingxiWhichQuestion) {
Map map1 = msg.getLocalExtension(); Map map1 = msg.getLocalExtension();
if (map1 == null) { if (map1 == null) {
map1 = new HashMap(); map1 = new HashMap();
map1.put("isExpired", true); map1.put("isExpired", true);
map1.put("position", position); map1.put("position", position);
msg.setLocalExtension(map1); msg.setLocalExtension(map1);
NIMClient.getService(MsgService.class).updateIMMessage(msg); NIMClient.getService(MsgService.class).updateIMMessage(msg);
//通知ui刷新 //通知ui刷新
getMsgAdapter().updateItemAtLocalExtension(msg); getMsgAdapter().updateItemAtLocalExtension(msg);
} }
} }
} }
} }
......
...@@ -12,6 +12,7 @@ data class LingxiWhichQuestionBean( ...@@ -12,6 +12,7 @@ data class LingxiWhichQuestionBean(
data class QuestionItemBean( data class QuestionItemBean(
var id:String?, var id:String?,
var name:String?, var name:String?,
var other:String?,
var relates:ArrayList<Relates>?, var relates:ArrayList<Relates>?,
var isSelected: Boolean=false var isSelected: Boolean=false
) )
...@@ -32,7 +33,7 @@ data class AnswerBean( ...@@ -32,7 +33,7 @@ data class AnswerBean(
data class AnswersItem( data class AnswersItem(
var optionId:String, var optionId:String,
var name: String, var name: String,
var other:String, var other:String?,
var relates:ArrayList<Relates> var relates:ArrayList<Relates>
) )
data class Relates( data class Relates(
......
...@@ -64,6 +64,9 @@ import com.yidianling.im.event.MultipleSelectedEvent; ...@@ -64,6 +64,9 @@ import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.helper.IMChatUtil; import com.yidianling.im.helper.IMChatUtil;
import com.yidianling.im.http.ImRetrofitApi; import com.yidianling.im.http.ImRetrofitApi;
import com.yidianling.im.router.ImIn; import com.yidianling.im.router.ImIn;
import com.yidianling.im.session.viewholder.bean.AnswerBean;
import com.yidianling.im.session.viewholder.bean.AnswersItem;
import com.yidianling.im.session.viewholder.bean.LingxiAnswerBean;
import com.yidianling.im.session.viewholder.bean.UserIsIn; import com.yidianling.im.session.viewholder.bean.UserIsIn;
import com.yidianling.im.session.viewholder.bean.UserIsInPageData; import com.yidianling.im.session.viewholder.bean.UserIsInPageData;
import com.yidianling.nimbase.api.UIKitOptions; import com.yidianling.nimbase.api.UIKitOptions;
...@@ -1079,25 +1082,57 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -1079,25 +1082,57 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
} }
public void onEvent(MultipleSelectedEvent event){ public void onEvent(MultipleSelectedEvent event){
if (event.getOthersState().isOthers()){ if (event.getOthersState()!=null){
//用户点击了其他事件 if (event.getOthersState().isOthers()){
if (event.getOthersState().getOthersSelect()){ //用户点击了其他事件
//其他是选中状态 if (event.getOthersState().getOthersSelect()){
isOthers=event.getOthersState().getOthersSelect(); //其他是选中状态
rootView.postDelayed(new Runnable() { isOthers=event.getOthersState().getOthersSelect();
@Override rootView.postDelayed(new Runnable() {
public void run() { @Override
inputPanel.onlyShowTextStart(); public void run() {
} inputPanel.onlyShowTextStart();
}, 500); }
}, 500);
}else{
//其他是未选中状态
isOthers=event.getOthersState().getOthersSelect();
inputPanel.onlyShowTextEnd();
}
}else{ }else{
//其他是未选中状态 question_multiple.setText(event.getStrSelected());
isOthers=event.getOthersState().getOthersSelect();
inputPanel.onlyShowTextEnd();
} }
}else{ }else{
question_multiple.setText(event.getStrSelected()); //请求接口发送消息为56的答案
ArrayList<AnswersItem> answersItems=event.getMultipleAnswerBean().getAnswersItems();
for (int i=0;i<answersItems.size();i++){
if (answersItems.get(i).getName().contains("其他")){
answersItems.get(i).setOther(inputPanel.getInputContent());
break;
}
}
answerLingxiQuestion(event.getMultipleAnswerBean().getExamId(),event.getMultipleAnswerBean().getQuestionPaperId(),
event.getMultipleAnswerBean().getUid(),event.getMultipleAnswerBean().getQuestionId(),answersItems,
event.getMultipleAnswerBean().getFromUid());
} }
}
/*
* 用户回答问题接口
* */
private void answerLingxiQuestion(String examID, String questionPaperId, String uid, String questionId, ArrayList<AnswersItem> answersItems,String fromUID) {
String str = new Gson().toJson(new LingxiAnswerBean(new AnswerBean(examID, questionPaperId, uid, questionId, answersItems), fromUID, "56", uid));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str);
Disposable subscribe = ImRetrofitApi.Companion.getImRetrofitApi().lingxiAnswerQuestion(body)
.compose(RxUtils.INSTANCE.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> {
LogUtil.e("answerQuestion" + it.toString());
}, throwable ->
com.yidianling.common.tools.LogUtil.e(throwable.getMessage())
);
} }
public boolean onBackPressed() { public boolean onBackPressed() {
return inputPanel.collapse(true) || messageListPanel.onBackPressed() || openOrCloseCommonQuestionLayout(false); return inputPanel.collapse(true) || messageListPanel.onBackPressed() || openOrCloseCommonQuestionLayout(false);
......
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