Commit 36b12cf9 by 刘鹏

Merge remote-tracking branch 'origin/4.2.60' into 4.2.60

# Conflicts:
#	config.gradle
parents 339f40ea 4b9462e5
...@@ -93,7 +93,7 @@ ext { ...@@ -93,7 +93,7 @@ ext {
"m-fm" : "0.0.30.01", "m-fm" : "0.0.30.01",
"m-user" : "0.0.61.37", "m-user" : "0.0.61.37",
"m-home" : "0.0.22.67", "m-home" : "0.0.22.67",
"m-im" : "0.0.19.33", "m-im" : "0.0.19.36",
"m-dynamic" : "0.0.7.24", "m-dynamic" : "0.0.7.24",
"m-article" : "0.0.0.8", "m-article" : "0.0.0.8",
......
...@@ -8,7 +8,7 @@ import java.util.ArrayList; ...@@ -8,7 +8,7 @@ import java.util.ArrayList;
public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{ public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
private final String ANSWERS = "answers"; private final String ANSWERS = "answers";
private final String QUESTIONID = "questionPaperId"; private final String QUESTIONID = "questionId";
public ArrayList<QuestionItemBean> answers; public ArrayList<QuestionItemBean> answers;
......
...@@ -47,14 +47,11 @@ import io.reactivex.schedulers.Schedulers; ...@@ -47,14 +47,11 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.RequestBody; import okhttp3.RequestBody;
public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiWhichQuestion.OnQuestionlItemClickListener, AdapterLingxiMultipleChoice.OnMultiplelItemClickListener { public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiMultipleChoice.OnMultiplelItemClickListener {
private RecyclerView recycleviewWhichQuestion;
private RecyclerView recycleviewMultipleChoice; private RecyclerView recycleviewMultipleChoice;
private TextView confirm_multiple_choice; private TextView confirm_multiple_choice;
private TextView which_question_title;
private TextView multiple_choice_title; private TextView multiple_choice_title;
private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion;
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice; private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>(); ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>();
...@@ -71,6 +68,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -71,6 +68,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private String singleOrMultipletype; private String singleOrMultipletype;
private ArrayList<AnswersItem> answersItems = new ArrayList<>(); private ArrayList<AnswersItem> answersItems = new ArrayList<>();
Map<String, Object> mapMessageFromCustom; Map<String, Object> mapMessageFromCustom;
Map map1 = new HashMap();
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) { public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter); super(adapter);
} }
...@@ -80,14 +79,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -80,14 +79,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment()); customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
singleOrMultipletype=customAttachLingxiWhichQuestion.type; singleOrMultipletype=customAttachLingxiWhichQuestion.type;
if (customAttachLingxiWhichQuestion.type != null) { if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type) { return R.layout.im_nim_lingxi_multiple_choice;
case "radio"://您想要咨询下列哪类的问题?(单选)
return R.layout.im_nim_lingxi_which_question;
case "check"://请问是发生了什么事情导致的呢?(多选)
return R.layout.im_nim_lingxi_multiple_choice;
default:
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;
} }
...@@ -96,10 +88,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -96,10 +88,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override @Override
protected void inflateContentView() { protected void inflateContentView() {
recycleviewWhichQuestion = findViewById(R.id.which_question_rv); // recycleviewWhichQuestion = findViewById(R.id.which_question_rv);
recycleviewMultipleChoice = findViewById(R.id.multiple_question_rv); recycleviewMultipleChoice = findViewById(R.id.multiple_question_rv);
confirm_multiple_choice = findViewById(R.id.confirm_multiple_choice); 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); multiple_choice_title = findViewById(R.id.multiple_choice_title);
} }
...@@ -116,7 +107,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -116,7 +107,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if (customAttachLingxiWhichQuestion.options != null) { if (customAttachLingxiWhichQuestion.options != null) {
questionList = (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options; questionList = (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options;
} }
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) {
...@@ -124,35 +114,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -124,35 +114,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
} }
} }
if (customAttachLingxiWhichQuestion.type != null) { if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type) { singleOrMultipletype=customAttachLingxiWhichQuestion.type;
case "radio"://您想要咨询下列哪类的问题?(单选) initMultipleChoice();
if (questionList != null && questionList.size() != 0) {
initSingleChoice();
}
break;
case "check"://请问是发生了什么事情导致的呢?(多选)
initMultipleChoice();
break;
default:
break;
}
} }
//进入消息列表时候,保存当type为56的时候的,将ID作为key保存 //进入消息列表时候,保存当type为56的时候的,将ID作为key保存
NIMClient.getService(MsgService.class).queryMessageList(message.getSessionId(),SessionTypeEnum.P2P,0,100).setCallback(new RequestCallback<List<IMMessage>>() { NIMClient.getService(MsgService.class).queryMessageList(message.getSessionId(),SessionTypeEnum.P2P,0,100).setCallback(new RequestCallback<List<IMMessage>>() {
@Override @Override
public void onSuccess(List<IMMessage> param) { public void onSuccess(List<IMMessage> param) {
if (param != null && param.size() > 0) { if (param != null && param.size() > 0) {
for (IMMessage msg : param) { for (IMMessage msg : param) {
MsgAttachment attachment = msg.getAttachment(); MsgAttachment attachment = msg.getAttachment();
if (attachment instanceof CustomAttachLingxiAnswerQuestion) { if (attachment instanceof CustomAttachLingxiAnswerQuestion) {
CustomAttachLingxiAnswerQuestion customattachlingxianswerquestion = (CustomAttachLingxiAnswerQuestion) attachment; CustomAttachLingxiAnswerQuestion customattachlingxianswerquestion = (CustomAttachLingxiAnswerQuestion) attachment;
Map map1 = msg.getLocalExtension();
map1 = new HashMap();
if (!map1.containsKey(customattachlingxianswerquestion.questionId)){
map1.put(customattachlingxianswerquestion.questionId, true); map1.put(customattachlingxianswerquestion.questionId, true);
} mapMessageFromCustom=map1;
mapMessageFromCustom=map1; UpdateFromLocalExtention();
UpdateFromLocalExtention(); LogUtil.e("aaaaaquestionID:"+customattachlingxianswerquestion.questionId);
}else{
//用户没有回答问题;
} }
} }
} }
...@@ -181,18 +162,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -181,18 +162,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
} }
if (mapMessage != null) { if (mapMessage != null) {
Object questionPaperId=mapMessage.get(customAttachLingxiWhichQuestion.questionPaperId); Object questionPaperId=mapMessage.get(customAttachLingxiWhichQuestion.id);
LogUtil.e("aaaaaIDIDI:"+customAttachLingxiWhichQuestion.id);
if (questionPaperId != null) { if (questionPaperId != null) {
boolean b = (boolean) questionPaperId; boolean b = (boolean) questionPaperId;
if (b) { if (b) {
//隐藏回答的信息 //隐藏回答的信息
if (singleOrMultipletype.contains("radio")){ recycleviewMultipleChoice.setVisibility(View.GONE);
recycleviewWhichQuestion.setVisibility(View.GONE); confirm_multiple_choice.setVisibility(View.GONE);
}else{ }else{
recycleviewMultipleChoice.setVisibility(View.GONE); recycleviewMultipleChoice.setVisibility(View.VISIBLE);
confirm_multiple_choice.setVisibility(View.GONE); confirm_multiple_choice.setVisibility(View.VISIBLE);
} }
}else{
//隐藏回答的信息
if (singleOrMultipletype.contains("radio")){
recycleviewMultipleChoice.setVisibility(View.VISIBLE);
}else{
recycleviewMultipleChoice.setVisibility(View.VISIBLE);
confirm_multiple_choice.setVisibility(View.VISIBLE);
} }
} }
} }
...@@ -203,7 +192,11 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -203,7 +192,11 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
} }
private void initMultipleChoice() { private void initMultipleChoice() {
if (singleOrMultipletype.contains("radio")){
confirm_multiple_choice.setVisibility(View.GONE);
}else{
confirm_multiple_choice.setVisibility(View.VISIBLE);
}
confirm_multiple_choice.setOnClickListener(view -> { confirm_multiple_choice.setOnClickListener(view -> {
//请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。 //请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。
EventBus.getDefault().post(new MultipleSelectedEvent(null, null, EventBus.getDefault().post(new MultipleSelectedEvent(null, null,
...@@ -222,79 +215,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -222,79 +215,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewMultipleChoice.setAdapter(adapterLingxiMultipleChoice); 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
public void onItemClick(@NotNull QuestionItemBean itemBean, int position) {
/*
* 单选题:分其他选项和非其他选项
* 其他选项,唤起输入框
* 点击非其他选项直接发送答案
* */
if (isClickable) {
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()) {
if (i == position) {
if (questionList.get(i).getName().contains("其他")){
isClickable = true;
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());
}else{
questionList.get(i).setSelected(false);
if (questionList.get(i).getName().contains("其他")){
selectedStr.remove(questionList.get(i).getName());
}
}
}
questionList.get(i).setSelected(i == position);
}
adapterLingxiWhichQuestion.setTagData(questionList, isSingleChoice);
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()){
answersItems.clear();
answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(), "", questionList.get(position).getRelates()));
break;
}
}
stringBuffer.delete(2, stringBuffer.length());
for (int i = 0; i < selectedStr.size(); i++) {
stringBuffer.append("#").append(selectedStr.get(i));
}
isOthers = questionList.get(position).getName().contains("其他");
if (!isOthers){
isClickable = false;
//请求接口发送所选题目
answerLingxiQuestion(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid().toString(), questionId, answersItems);
//更新本地消息
updateLocalMsg(position,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,true));
}else{
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,false));
}
}
}
/* /*
* 用户回答问题接口 * 用户回答问题接口
...@@ -316,52 +237,110 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen ...@@ -316,52 +237,110 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override @Override
public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) { public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) {
if (isClickable){ if (singleOrMultipletype.contains("radio")){
//多选发送消息 /*
for (int i = 0; i < questionList.size(); i++) { * 单选题:分其他选项和非其他选项
if (questionList.get(i).isSelected()) { * 其他选项,唤起输入框
if (i == position) { * 点击非其他选项直接发送答案
questionList.get(i).setSelected(false); * */
selectedStr.remove(questionList.get(i).getName()); for (int i = 0; i < questionList.size(); i++) {
for (int j=0;j<answersItems.size();j++){ if (questionList.get(i).isSelected()) {
if (questionList.get(i).getName()==answersItems.get(j).getName()){ if (i == position) {
answersItems.remove(j); if (questionList.get(i).getName().contains("其他")){
break; isClickable = true;
} 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());
}else{
questionList.get(i).setSelected(false);
if (questionList.get(i).getName().contains("其他")){
selectedStr.remove(questionList.get(i).getName());
}
}
}
questionList.get(i).setSelected(i == position);
}
adapterLingxiMultipleChoice.setTagData(questionList);
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()){
answersItems.clear();
answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(), "", questionList.get(position).getRelates()));
break;
}
}
stringBuffer.delete(2, stringBuffer.length());
for (int i = 0; i < selectedStr.size(); i++) {
stringBuffer.append("#").append(selectedStr.get(i));
}
isOthers = questionList.get(position).getName().contains("其他");
if (!isOthers){
isClickable = false;
//请求接口发送所选题目
answerLingxiQuestion(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid().toString(), questionId, answersItems);
//更新本地消息
updateLocalMsg(position,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,true));
}else{
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,false));
}
}else{
//多选发送消息
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()) {
if (i == position) {
questionList.get(i).setSelected(false);
selectedStr.remove(questionList.get(i).getName());
for (int j=0;j<answersItems.size();j++){
if (questionList.get(i).getName()==answersItems.get(j).getName()){
answersItems.remove(j);
break;
}
}
}
} else {
if (i == position) {
questionList.get(i).setSelected(true);
selectedStr.add(questionList.get(i).getName());
answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(), "", questionList.get(position).getRelates()));
}
}
}
confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size()));
if (selectedStr.size() > 0) {
confirm_multiple_choice.setEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2));
}
} else {
confirm_multiple_choice.setEnabled(false);
confirm_multiple_choice.setText("确定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getDrawable(R.drawable.im_background_18dp_ebebeb));
}
}
stringBuffer.delete(2, stringBuffer.length());
for (int i = 0; i < selectedStr.size(); i++) {
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()), new MultipleAnswerBean(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),
questionId, answersItems,message.getFromAccount()),false,false));
adapterLingxiMultipleChoice.setTagData(questionList);
}
}
} else {
if (i == position) {
questionList.get(i).setSelected(true);
selectedStr.add(questionList.get(i).getName());
answersItems.add(new AnswersItem(questionList.get(position).getId(),
questionList.get(position).getName(), "", questionList.get(position).getRelates()));
}
}
}
confirm_multiple_choice.setText(String.format("确定(%d)", selectedStr.size()));
if (selectedStr.size() > 0) {
confirm_multiple_choice.setEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getResources().getDrawable(R.drawable.im_background_18dp_1da1f2));
}
} else {
confirm_multiple_choice.setEnabled(false);
confirm_multiple_choice.setText("确定");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
confirm_multiple_choice.setBackground(context.getDrawable(R.drawable.im_background_18dp_ebebeb));
}
}
stringBuffer.delete(2, stringBuffer.length());
for (int i = 0; i < selectedStr.size(); i++) {
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()), new MultipleAnswerBean(examId, questionPaperId, ImIn.INSTANCE.getUserInfo().getUid(),
questionId, answersItems,message.getFromAccount()),false,false));
adapterLingxiMultipleChoice.setTagData(questionList);
}
} }
private void updateLocalMsg(Integer position,ArrayList<String> selectedPosition) { private void updateLocalMsg(Integer position,ArrayList<String> selectedPosition) {
......
...@@ -285,7 +285,12 @@ public class MessageListPanelEx { ...@@ -285,7 +285,12 @@ public class MessageListPanelEx {
} }
if (needRefresh) { if (needRefresh) {
sortMessages(items); sortMessages(items);
adapter.notifyDataSetChanged(); new Handler().post(new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
}
});
} }
adapter.updateShowTimeItem(addedListItems, false, true); adapter.updateShowTimeItem(addedListItems, false, true);
......
...@@ -13,6 +13,6 @@ ...@@ -13,6 +13,6 @@
android:includeFontPadding="false" android:includeFontPadding="false"
android:lineSpacingExtra="3dip" android:lineSpacingExtra="3dip"
android:minHeight="40dp" android:minHeight="40dp"
android:textColor="@color/white" android:textColor="@color/im_color_242424"
android:textSize="17dp"/> android:textSize="17dp"/>
</LinearLayout> </LinearLayout>
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