Commit 4c3c4016 by 霍志良

feat:im-灵犀2.0-发送按钮发送通知

parent a4036e54
......@@ -6,7 +6,8 @@ import com.yidianling.im.session.viewholder.bean.AnswersItem
public class MultipleSelectedEvent (
val strSelected:String?,
var othersState:OthersState?,
var multipleAnswerBean:MultipleAnswerBean?
var multipleAnswerBean:MultipleAnswerBean?,
var isFromInputPanel:Boolean
)
data class OthersState(
var isOthers:Boolean,
......
......@@ -176,7 +176,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
//请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。
EventBus.getDefault().post(new MultipleSelectedEvent(null, null,
new MultipleAnswerBean(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),
questionId, answersItems,message.getFromAccount())));
questionId, answersItems,message.getFromAccount()),false));
});
multiple_choice_title.setText(customAttachLingxiWhichQuestion.name);
adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
......@@ -281,7 +281,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
stringBuffer.append("#").append(selectedStr.get(i));
}
isOthers = questionList.get(position).getName().contains("其他");
EventBus.getDefault().post(new MultipleSelectedEvent(stringBuffer.toString(), new OthersState(isOthers, questionList.get(position).isSelected()), 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));
adapterLingxiMultipleChoice.setTagData(questionList);
......
......@@ -60,6 +60,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.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.helper.IMChatUtil;
import com.yidianling.im.http.ImRetrofitApi;
......@@ -224,6 +225,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private UserInfoDialog userInfoDialog = null;
private boolean isOthers;
private MultipleAnswerBean multipleAnswerBean;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
......@@ -1081,8 +1083,12 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
userIsInPage("67","用户离开当前页面",sessionId,ImIn.INSTANCE.getUserInfo().getUid());
}
ArrayList<AnswersItem> answersItems = new ArrayList<>();
public void onEvent(MultipleSelectedEvent event){
if (event.getOthersState()!=null){
answersItems=event.getMultipleAnswerBean().getAnswersItems();
multipleAnswerBean=event.getMultipleAnswerBean();
multipleAnswerBean.setAnswersItems(answersItems);
if (event.getOthersState().isOthers()){
//用户点击了其他事件
if (event.getOthersState().getOthersSelect()){
......@@ -1102,24 +1108,41 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}else{
question_multiple.setText(event.getStrSelected());
}
}else if (event.isFromInputPanel()){
for (int i=0;i<answersItems.size();i++){
if (answersItems.get(i).getName().contains("其他")){
answersItems.get(i).setOther(inputPanel.getInputContent());
break;
}
}
multipleAnswerBean.setAnswersItems(answersItems);
answerMultipleQuestion(multipleAnswerBean);
}else{
//请求接口发送消息为56的答案
inputPanel.setInputContent("");
question_multiple.setText("");
inputPanel.onlyShowTextEnd();
ArrayList<AnswersItem> answersItems=event.getMultipleAnswerBean().getAnswersItems();
//请求接口发送消息为56的答案
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());
multipleAnswerBean=event.getMultipleAnswerBean();
multipleAnswerBean.setAnswersItems(answersItems);
answerMultipleQuestion(multipleAnswerBean);
}
}
/*
* 用户回答问题接口
* */
private void answerMultipleQuestion(MultipleAnswerBean multipleAnswerBean){
inputPanel.setInputContent("");
question_multiple.setText("");
inputPanel.onlyShowTextEnd();
answerLingxiQuestion(multipleAnswerBean.getExamId(),multipleAnswerBean.getQuestionPaperId(),
multipleAnswerBean.getUid(),multipleAnswerBean.getQuestionId(),multipleAnswerBean.getAnswersItems(),
multipleAnswerBean.getFromUid());
}
/*
* 用户回答问题接口
......
......@@ -42,6 +42,9 @@ import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.im.event.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.router.ImIn;
import com.yidianling.nimbase.api.UIKitOptions;
import com.yidianling.nimbase.api.model.session.SessionCustomization;
import com.yidianling.nimbase.business.session.actions.BaseAction;
......@@ -62,6 +65,7 @@ import com.yidianling.uikit.custom.widget.SafeHelpRemindDialog;
import java.io.File;
import java.util.List;
import de.greenrobot.event.EventBus;
import io.reactivex.functions.Consumer;
/**
......@@ -412,7 +416,12 @@ public class InputPanel implements IEmoticonSelectedListener, IAudioRecordCallba
if (v == switchToTextButtonInInputBar) {
switchToTextLayout(true);// 显示文本发送的布局
} else if (v == sendMessageButtonInInputBar) {
onTextMessageSendButtonPressed();
if (onlyShowInputTest){
EventBus.getDefault().post(new MultipleSelectedEvent(null, null,
null,true));
}else{
onTextMessageSendButtonPressed();
}
} else if (v == switchToAudioButtonInInputBar) {
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO)
.subscribe(new Consumer<Permission>() {
......
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