Commit b052d78e by 霍志良

feat:im-灵犀2.0-回答问题

parent 560634fe
package com.yidianling.im.session.extension;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import java.util.ArrayList;
public class CustomAttachLingxiAnswerQuestion extends CustomAttachment{
private final String QUESTIONPAPERID = "questionPaperId";//试卷id
private final String ANSWERS = "answers";//试卷id
public String questionPaperId;
public ArrayList<QuestionItemBean> answers;
public CustomAttachLingxiAnswerQuestion() {
super(CustomAttachmentType.TYPE_LINGXI_ANSWER_QUESTION);
}
@Override
protected void parseData(JSONObject data) {
this.questionPaperId = data.getString(QUESTIONPAPERID);
this.answers=(ArrayList<QuestionItemBean>) JSON.parseArray(data.getString(ANSWERS), QuestionItemBean.class);
}
@Override
protected JSONObject packData() {
JSONObject data = new JSONObject();
data.put(QUESTIONPAPERID, questionPaperId);
data.put(ANSWERS, answers);
return data;
}
}
package com.yidianling.im.session.viewholder;
import android.view.Gravity;
import android.widget.TextView;
import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachLingxiAnswerQuestion;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
private TextView answer_question;
CustomAttachLingxiAnswerQuestion customattachLingxiAnswerQuestion;
public MsgViewHolderLingxiAnswerQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
......@@ -19,6 +23,7 @@ public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
@Override
protected void inflateContentView() {
answer_question = findViewById(R.id.answer_question);
}
......@@ -30,6 +35,8 @@ public class MsgViewHolderLingxiAnswerQuestion extends MsgViewHolderBase {
@Override
protected void bindContentView() {
customattachLingxiAnswerQuestion = ((CustomAttachLingxiAnswerQuestion) message.getAttachment());
answer_question.setText(customattachLingxiAnswerQuestion.answers.get(0).getName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_c2e7ff" />
<corners
android:topLeftRadius="@dimen/platform_dp_10"
android:bottomRightRadius="@dimen/platform_dp_10"
android:bottomLeftRadius="@dimen/platform_dp_10"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="aaa"
android:background="@color/color_c2e7ff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
tools:text="答案"
android:background="@drawable/im_custom_message_round_c2e7ff_6dp_bg"
android:id="@+id/answer_question"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_sp_14"
android:paddingTop="@dimen/platform_dp_9"
android:paddingBottom="@dimen/platform_dp_9"
android:paddingStart="@dimen/platform_dp_10"
android:paddingEnd="@dimen/platform_dp_10"
>
android:paddingEnd="@dimen/platform_dp_10">
</TextView>
\ No newline at end of file
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