Commit ee80ff49 by 霍志良

feat:当回答问题的时候,隐藏答案

parent 114024fa
......@@ -7,10 +7,12 @@ import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import java.util.ArrayList;
public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
private final String ANSWERS = "answers";//试卷id
private final String ANSWERS = "answers";
private final String QUESTIONID = "questionPaperId";
public ArrayList<QuestionItemBean> answers;
public String questionId;
public CustomAttachLingxiAnswerQuestion() {
super(CustomAttachmentType.TYPE_LINGXI_ANSWER_QUESTION);
......@@ -18,12 +20,14 @@ public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
@Override
protected void parseData(JSONObject data) {
this.answers=(ArrayList<QuestionItemBean>) JSON.parseArray(data.getString(ANSWERS), QuestionItemBean.class);
this.questionId = data.getString(QUESTIONID);
}
@Override
protected JSONObject packData() {
JSONObject data = new JSONObject();
data.put(ANSWERS, answers);
data.put(QUESTIONID, questionId);
return data;
}
}
package com.yidianling.im.session.viewholder;
import android.os.Build;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
......@@ -21,6 +22,7 @@ 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.CustomAttachLingxiAnswerQuestion;
import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion;
import com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice;
import com.yidianling.im.session.viewholder.adapter.AdapterLingxiWhichQuestion;
......@@ -66,9 +68,10 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private String examId;
private String questionPaperId;
private String questionId;
private String singleOrMultipletype;
private ArrayList<AnswersItem> answersItems = new ArrayList<>();
private ArrayList<String> multipleAnswers=new ArrayList<>();
Map<String, Object> mapMessageFromCustom;
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
......@@ -76,6 +79,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected int getContentResId() {
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
singleOrMultipletype=customAttachLingxiWhichQuestion.type;
if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type) {
case "radio"://您想要咨询下列哪类的问题?(单选)
......@@ -134,46 +138,58 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
break;
}
}
UpdateFromLocalExtention();
//进入消息列表时候,保存当type为56的时候的,将ID作为key保存
NIMClient.getService(MsgService.class).queryMessageList(message.getSessionId(),SessionTypeEnum.P2P,0,100).setCallback(new RequestCallback<List<IMMessage>>() {
@Override
public void onSuccess(List<IMMessage> param) {
if (param != null && param.size() > 0) {
for (IMMessage msg : param) {
MsgAttachment attachment = msg.getAttachment();
if (attachment instanceof CustomAttachLingxiAnswerQuestion) {
CustomAttachLingxiAnswerQuestion customattachlingxianswerquestion = (CustomAttachLingxiAnswerQuestion) attachment;
Map map1 = msg.getLocalExtension();
map1 = new HashMap();
if (!map1.containsKey(customattachlingxianswerquestion.questionId)){
map1.put(customattachlingxianswerquestion.questionId, true);
}
mapMessageFromCustom=map1;
UpdateFromLocalExtention();
}
}
}
}
@Override
public void onFailed(int code) {
LogUtil.e("获取消息onFailed:"+code);
}
@Override
public void onException(Throwable exception) {
LogUtil.e("获取消息exception:"+exception.getLocalizedMessage());
}
});
}
private void UpdateFromLocalExtention() {
try {
Map<String, Object> map = message.getLocalExtension();
if (map != null) {
Object obj = map.get("isSure");
Object position = map.get("position");
Object multiple = map.get("multiple");
if (obj != null) {
boolean b = (boolean) obj;
Integer posi = (Integer) position;
if (b) {
//不可点击
isClickable = false;
if (posi!=null){
questionList.get(posi).setSelected(true);
}
}
} else {
//可点击
}
if (multiple!=null){
multipleAnswers= (ArrayList<String>) multiple;
for (int i=0;i<questionList.size();i++){
for (int j=0;j<multipleAnswers.size();j++){
if (questionList.get(i).getName().contains(multipleAnswers.get(j))){
questionList.get(i).setSelected(true);
}
}
}
if (isClickable){
confirm_multiple_choice.setEnabled(true);
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_ebebeb));
Map<String, Object> mapMessage;
if (mapMessageFromCustom!=null){
mapMessage=mapMessageFromCustom;
}else{
mapMessage= message.getLocalExtension();
}
if (mapMessage != null) {
Object questionPaperId=mapMessage.get(customAttachLingxiWhichQuestion.questionPaperId);
if (questionPaperId.toString().equals("true")){
//隐藏回答的信息
if (singleOrMultipletype.contains("radio")){
recycleviewWhichQuestion.setVisibility(View.GONE);
}else{
confirm_multiple_choice.setEnabled(false);
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2));
confirm_multiple_choice.setText("确定("+multipleAnswers.size()+")");
recycleviewMultipleChoice.setVisibility(View.GONE);
confirm_multiple_choice.setVisibility(View.GONE);
}
}
......@@ -182,7 +198,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
} catch (Exception e) {
LogUtil.e("aaaaa"+e.getLocalizedMessage());
LogUtil.e(e.getLocalizedMessage());
}
}
......
......@@ -36,6 +36,7 @@ import com.netease.nimlib.sdk.ResponseCode;
import com.netease.nimlib.sdk.msg.MessageBuilder;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.MsgServiceObserve;
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.CustomMessageConfig;
......@@ -65,6 +66,8 @@ import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.helper.IMChatUtil;
import com.yidianling.im.http.ImRetrofitApi;
import com.yidianling.im.router.ImIn;
import com.yidianling.im.session.extension.CustomAttachLingxiAnswerQuestion;
import com.yidianling.im.session.extension.CustomAttachmentConfirmOrder;
import com.yidianling.im.session.viewholder.bean.AnswerBean;
import com.yidianling.im.session.viewholder.bean.AnswersItem;
import com.yidianling.im.session.viewholder.bean.LingxiAnswerBean;
......@@ -272,8 +275,8 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
ll_info_detail = rootView.findViewById(R.id.ll_info_detail);
tv_doctor_name = rootView.findViewById(R.id.tv_doctor_name);
rl_contain = rootView.findViewById(R.id.rl_contain);
//和助理私聊时的常用语逻辑
messageListView.setItemAnimator(null);
//和助理私聊时的常用语逻辑
// rl_common_question_enter = rootView.findViewById(R.id.rl_common_question);
fl_question_content = rootView.findViewById(R.id.fl_question_content);
question_multiple = rootView.findViewById(R.id.question_multiple);
......@@ -783,7 +786,6 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
} catch (Exception e) {
LogUtil.i(e.toString());
}
if (!TextUtils.isEmpty(headUrl)) {
IP2PCustomActionHandler.DocInfo info = ActionHandlerStorage.getL(sessionId).getInfo();
if (null != info) {
......
......@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="婚姻家庭婚姻混"
android:text="婚姻家庭婚"
android:textColor="@color/platform_color_1DA1F2"
android:gravity="center"
android:minWidth="110dp"
......@@ -11,7 +11,7 @@
android:paddingTop="@dimen/platform_dp_8"
android:paddingBottom="@dimen/platform_dp_8"
android:id="@+id/tv_which_question"
android:layout_marginTop="@dimen/platform_dp_16"
android:layout_marginBottom="@dimen/platform_dp_16"
android:layout_marginRight="@dimen/platform_dp_9"
android:paddingStart="@dimen/platform_dp_25"
android:paddingEnd="@dimen/platform_dp_25"
......
......@@ -2,6 +2,7 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="263dp"
xmlns:tools="http://schemas.android.com/tools"
tools:text="答案"
android:background="@drawable/im_custom_message_round_c2e7ff_6dp_bg"
......
......@@ -2,11 +2,13 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="263dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/im_custom_message_round_white_6dp_bg"
android:paddingLeft="@dimen/platform_dp_12"
android:paddingRight="@dimen/platform_dp_3"
android:paddingTop="@dimen/platform_dp_12"
>
<TextView
android:layout_width="239dp"
......@@ -17,6 +19,7 @@
tools:text="请问是发生了什么事情导致的呢?(多选)?"
android:textSize="@dimen/im_text_size_17"
android:textColor="@color/im_color_242424"
android:paddingBottom="@dimen/platform_dp_16"
>
</TextView>
<androidx.recyclerview.widget.RecyclerView
......@@ -37,7 +40,7 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/multiple_question_rv"
android:text="确定(0)"
android:layout_marginTop="@dimen/platform_dp_24"
android:layout_marginTop="@dimen/platform_dp_8"
android:textSize="@dimen/im_text_size_15"
android:enabled="false"
app:layout_constraintEnd_toEndOf="@id/multiple_question_rv"
......
......@@ -2,27 +2,33 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_width="263dp"
android:layout_height="wrap_content"
android:background="@drawable/im_custom_message_round_white_6dp_bg"
android:paddingLeft="@dimen/platform_dp_12"
android:paddingRight="@dimen/platform_dp_3">
android:paddingRight="@dimen/platform_dp_3"
android:paddingTop="@dimen/platform_dp_12"
>
<TextView
android:id="@+id/which_question_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="您想要咨询下类哪类问题?" />
tools:text="您想要咨询下类哪类问题您想要咨询下类哪类问题?"
android:layout_marginBottom="@dimen/platform_dp_16"
app:layout_constraintBottom_toTopOf="@id/which_question_rv"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/which_question_rv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/platform_dp_16"
android:layout_marginBottom="@dimen/dp_4"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/platform_color_F0F0F0"
android:background="@color/color_f8f8f8"
android:orientation="vertical">
<FrameLayout
......
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