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 {
"m-fm" : "0.0.30.01",
"m-user" : "0.0.61.37",
"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-article" : "0.0.0.8",
......
......@@ -8,7 +8,7 @@ import java.util.ArrayList;
public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
private final String ANSWERS = "answers";
private final String QUESTIONID = "questionPaperId";
private final String QUESTIONID = "questionId";
public ArrayList<QuestionItemBean> answers;
......
......@@ -47,14 +47,11 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiWhichQuestion.OnQuestionlItemClickListener, AdapterLingxiMultipleChoice.OnMultiplelItemClickListener {
private RecyclerView recycleviewWhichQuestion;
public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implements AdapterLingxiMultipleChoice.OnMultiplelItemClickListener {
private RecyclerView recycleviewMultipleChoice;
private TextView confirm_multiple_choice;
private TextView which_question_title;
private TextView multiple_choice_title;
private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion;
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>();
......@@ -71,6 +68,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private String singleOrMultipletype;
private ArrayList<AnswersItem> answersItems = new ArrayList<>();
Map<String, Object> mapMessageFromCustom;
Map map1 = new HashMap();
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
......@@ -80,14 +79,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
singleOrMultipletype=customAttachLingxiWhichQuestion.type;
if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type) {
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 {
return R.layout.im_nim_lingxi_which_question;
}
......@@ -96,10 +88,9 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected void inflateContentView() {
recycleviewWhichQuestion = findViewById(R.id.which_question_rv);
// recycleviewWhichQuestion = findViewById(R.id.which_question_rv);
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);
}
......@@ -116,7 +107,6 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
if (customAttachLingxiWhichQuestion.options != null) {
questionList = (ArrayList<QuestionItemBean>) customAttachLingxiWhichQuestion.options;
}
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
for (int i = 0; i < questionList.size(); i++) {
questionList.get(i).setSelected(false);
if (questionList.get(i).getName().length() > 5) {
......@@ -124,35 +114,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
}
if (customAttachLingxiWhichQuestion.type != null) {
switch (customAttachLingxiWhichQuestion.type) {
case "radio"://您想要咨询下列哪类的问题?(单选)
if (questionList != null && questionList.size() != 0) {
initSingleChoice();
}
break;
case "check"://请问是发生了什么事情导致的呢?(多选)
singleOrMultipletype=customAttachLingxiWhichQuestion.type;
initMultipleChoice();
break;
default:
break;
}
}
//进入消息列表时候,保存当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();
LogUtil.e("aaaaaquestionID:"+customattachlingxianswerquestion.questionId);
}else{
//用户没有回答问题;
}
}
}
......@@ -181,18 +162,26 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
if (mapMessage != null) {
Object questionPaperId=mapMessage.get(customAttachLingxiWhichQuestion.questionPaperId);
Object questionPaperId=mapMessage.get(customAttachLingxiWhichQuestion.id);
LogUtil.e("aaaaaIDIDI:"+customAttachLingxiWhichQuestion.id);
if (questionPaperId != null) {
boolean b = (boolean) questionPaperId;
if (b) {
//隐藏回答的信息
if (singleOrMultipletype.contains("radio")){
recycleviewWhichQuestion.setVisibility(View.GONE);
}else{
recycleviewMultipleChoice.setVisibility(View.GONE);
confirm_multiple_choice.setVisibility(View.GONE);
}else{
recycleviewMultipleChoice.setVisibility(View.VISIBLE);
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
}
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 -> {
//请求接口发送所选题目,通过发通知到YDLMessageFragment统一回答问题。
EventBus.getDefault().post(new MultipleSelectedEvent(null, null,
......@@ -222,27 +215,34 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
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);
/*
* 用户回答问题接口
* */
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), uid, "56", message.getFromAccount()));
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 ->
LogUtil.e(throwable.getMessage())
);
}
@Override
public void onItemClick(@NotNull QuestionItemBean itemBean, int position) {
@Override
public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) {
if (singleOrMultipletype.contains("radio")){
/*
* 单选题:分其他选项和非其他选项
* 其他选项,唤起输入框
* 点击非其他选项直接发送答案
* */
if (isClickable) {
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()) {
if (i == position) {
......@@ -265,7 +265,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
questionList.get(i).setSelected(i == position);
}
adapterLingxiWhichQuestion.setTagData(questionList, isSingleChoice);
adapterLingxiMultipleChoice.setTagData(questionList);
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()){
answersItems.clear();
......@@ -293,30 +293,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
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));
}
}
}
/*
* 用户回答问题接口
* */
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), uid, "56", message.getFromAccount()));
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 ->
LogUtil.e(throwable.getMessage())
);
}
@Override
public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) {
if (isClickable){
}else{
//多选发送消息
for (int i = 0; i < questionList.size(); i++) {
if (questionList.get(i).isSelected()) {
......@@ -362,6 +339,8 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
questionId, answersItems,message.getFromAccount()),false,false));
adapterLingxiMultipleChoice.setTagData(questionList);
}
}
private void updateLocalMsg(Integer position,ArrayList<String> selectedPosition) {
......
......@@ -285,8 +285,13 @@ public class MessageListPanelEx {
}
if (needRefresh) {
sortMessages(items);
new Handler().post(new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
}
});
}
adapter.updateShowTimeItem(addedListItems, false, true);
......
......@@ -13,6 +13,6 @@
android:includeFontPadding="false"
android:lineSpacingExtra="3dip"
android:minHeight="40dp"
android:textColor="@color/white"
android:textColor="@color/im_color_242424"
android:textSize="17dp"/>
</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