Commit 6233367b by 霍志良

feat:更新本地消息

parent 6302007a
package com.yidianling.im.event
import com.yidianling.im.router.ImIn.getUserInfo
import com.yidianling.im.session.viewholder.bean.AnswersItem
public class MultipleSelectedEvent (
......
......@@ -9,6 +9,7 @@ import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.RequestCallback
import com.netease.nimlib.sdk.auth.LoginInfo
import com.netease.nimlib.sdk.msg.MsgService
import com.netease.nimlib.sdk.msg.model.IMMessage
import com.netease.nimlib.sdk.uinfo.UserService
import com.netease.nimlib.sdk.uinfo.constant.UserInfoFieldEnum
import com.ydl.confide.api.IConfideService
......@@ -301,4 +302,12 @@ object ImIn {
fun loginByOneKeyLogin(context: Context, isOpenDialog: Boolean) :Boolean{
return getUserService().loginByOneKeyLogin(context,isOpenDialog)
}
lateinit var imMessage:IMMessage
fun setLocalExten(imMessage:IMMessage){
this.imMessage=imMessage
}
fun getImmessage():IMMessage {
return imMessage
}
}
package com.yidianling.im.session.viewholder.bean
import android.os.Parcel
import android.os.Parcelable
import java.io.Serializable
data class LingxiWhichQuestionBean(
var isSelected: Boolean,
......@@ -30,18 +34,20 @@ data class AnswerBean(
var questionId:String,
var answers:ArrayList<AnswersItem>
)
data class AnswersItem(
class AnswersItem(
var optionId:String,
var name: String,
var other:String?,
var relates:ArrayList<Relates>
)
data class Relates(
class Relates(
var id: String?,
var category:String?,
var name: String?,
var score:String?
)
data class UserIsIn(
var data: UserIsInPageData,
var fromUid: String,
......
......@@ -110,6 +110,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -226,6 +227,8 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private UserInfoDialog userInfoDialog = null;
private boolean isOthers;
private MultipleAnswerBean multipleAnswerBean;
private ArrayList<String> answersItemsMap = new ArrayList<>();
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
......@@ -1116,6 +1119,10 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
}
multipleAnswerBean.setAnswersItems(answersItems);
for (int i=0;i<answersItems.size();i++){
answersItemsMap.add(i,answersItems.get(i).getName());
}
updateLocalMsg(null,answersItemsMap);
answerMultipleQuestion(multipleAnswerBean);
}else{
......@@ -1129,14 +1136,37 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
multipleAnswerBean=event.getMultipleAnswerBean();
multipleAnswerBean.setAnswersItems(answersItems);
for (int i=0;i<answersItems.size();i++){
answersItemsMap.add(i,answersItems.get(i).getName());
}
updateLocalMsg(null,answersItemsMap);
answerMultipleQuestion(multipleAnswerBean);
}
}
private void updateLocalMsg(Integer position,ArrayList<String> selectedPosition) {
IMMessage message=ImIn.INSTANCE.getImMessage();
//更新本地消息
Map<String, Object> map = message.getLocalExtension();
if (map == null) {
map = new HashMap();
}
map.put("isSure", true);
if (position!=null){
map.put("position", position);
}
if (selectedPosition!=null){
map.put("multiple", selectedPosition);
}
message.setLocalExtension(map);
NIMClient.getService(MsgService.class).updateIMMessage(message);
//通知ui刷新
// message.getMsgAdapter().updateItemAtLocalExtension(message);
}
/*
* 用户回答问题接口
* */
private void answerMultipleQuestion(MultipleAnswerBean multipleAnswerBean){
inputPanel.setInputContent("");
question_multiple.setText("");
inputPanel.onlyShowTextEnd();
......@@ -1148,7 +1178,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
* 用户回答问题接口
* */
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));
String str = new Gson().toJson(new LingxiAnswerBean(new AnswerBean(examID, questionPaperId, uid, questionId, answersItems), uid, "56", fromUID));
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str);
Disposable subscribe = ImRetrofitApi.Companion.getImRetrofitApi().lingxiAnswerQuestion(body)
.compose(RxUtils.INSTANCE.resultJavaData())
......
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