Commit c843762f by 霍志良

feat:im-灵犀2.0-Json字段调整

parent 604a6502
package com.yidianling.im.session.extension;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import com.yidianling.uikit.custom.http.response.RecommendExpertBean;
import java.util.ArrayList;
import java.util.List;
public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
private final String XQUESTIONPAPERID = "xquestionPaperId";//试卷id
......@@ -11,12 +18,12 @@ public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
private final String SELECTVALS = "selectVals";//选项
private String xquestionPaperId;
private String xquestionPaperName;
private String questionId;
private String questionTitle;
private String selectType;
private String selectVals;
public String xquestionPaperId;
public String xquestionPaperName;
public String questionId;
public String questionTitle;
public String selectType;
public List<QuestionItemBean> selectVals;
public CustomAttachLingxiWhichQuestion() {
super(CustomAttachmentType.TYPE_LINGXI_WHICH_QUESTION);
......@@ -25,6 +32,12 @@ public class CustomAttachLingxiWhichQuestion extends CustomAttachment {
@Override
protected void parseData(JSONObject data) {
this.xquestionPaperId = data.getString(XQUESTIONPAPERID);
this.xquestionPaperName = data.getString(XQUESTIONPAPERNAME);
this.questionId = data.getString(QUESTIONID);
this.questionTitle = data.getString(QUESTIONTITLE);
this.selectType = data.getString(SELECTTYPE);
this.selectVals=(ArrayList<QuestionItemBean>)JSON.parseArray(data.getString(SELECTVALS), QuestionItemBean.class);
}
@Override
......
......@@ -11,6 +11,7 @@ import com.yidianling.im.session.extension.CustomAttachmentOrderStatus;
import com.yidianling.im.session.viewholder.adapter.AdapterLingxiMultipleChoice;
import com.yidianling.im.session.viewholder.adapter.AdapterLingxiWhichQuestion;
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean;
import com.yidianling.im.session.viewholder.bean.QuestionItemBean;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
......@@ -24,17 +25,18 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
private AdapterLingxiWhichQuestion adapterLingxiWhichQuestion;
private AdapterLingxiMultipleChoice adapterLingxiMultipleChoice;
ArrayList<String> questionList = new ArrayList<String>();
ArrayList<QuestionItemBean> questionList = new ArrayList<QuestionItemBean>();
Integer maxItemSize = 6;
Boolean isSingleChoice=true;
CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion;
public MsgViewHolderLingxiWhichQuestion(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
@Override
protected int getContentResId() {
CustomAttachLingxiWhichQuestion customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
switch (customAttachLingxiWhichQuestion.getType()){
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
switch (Integer.parseInt(customAttachLingxiWhichQuestion.selectType)){
case 1://您想要咨询下列哪类的问题?(单选)
return R.layout.im_nim_lingxi_which_question;
case 2://请问是发生了什么事情导致的呢?(多选)
......@@ -55,16 +57,15 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
@Override
protected void bindContentView() {
questionList.add("aaa");
questionList.add("aaa");
questionList.add("aaa");
questionList.add("aaa");
questionList.add("aaa");
questionList.add("aaa");
customAttachLingxiWhichQuestion = ((CustomAttachLingxiWhichQuestion) message.getAttachment());
//您想要咨询下列哪类的问题?(单选)
adapterLingxiWhichQuestion = new AdapterLingxiWhichQuestion();
for (int i=0;i<8;i++){
questionList.add(new QuestionItemBean("1","婚姻情感"));
}
adapterLingxiWhichQuestion.setTagData(questionList);
adapterLingxiWhichQuestion.setItemListener(this);
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2);
//当list中字段大于6个显示单行,否则显示双行
gridLayoutManager.setSpanCount(maxItemSize > 6 ? 1 : 2);
......@@ -73,19 +74,19 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
recycleviewWhichQuestion.setAdapter(adapterLingxiWhichQuestion);
//请问是发生了什么事情导致的呢?(多选)
adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
adapterLingxiMultipleChoice.setTagData(questionList);
GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2);
//当list中字段大于6个显示单行,否则显示双行
multipleChoiceManager.setSpanCount(maxItemSize > 6 ? 1 : 2);
multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL);
recycleviewWhichQuestion.setLayoutManager(multipleChoiceManager);
recycleviewWhichQuestion.setAdapter(adapterLingxiMultipleChoice);
// adapterLingxiMultipleChoice = new AdapterLingxiMultipleChoice();
//// adapterLingxiMultipleChoice.setTagData(questionList);
// GridLayoutManager multipleChoiceManager = new GridLayoutManager(context, 2);
// //当list中字段大于6个显示单行,否则显示双行
// multipleChoiceManager.setSpanCount(maxItemSize > 6 ? 1 : 2);
// multipleChoiceManager.setOrientation(GridLayoutManager.VERTICAL);
// recycleviewWhichQuestion.setLayoutManager(multipleChoiceManager);
// recycleviewWhichQuestion.setAdapter(adapterLingxiMultipleChoice);
}
@Override
public void onItemClick(@NotNull LingxiWhichQuestionBean string, int position) {
public void onItemClick(@NotNull QuestionItemBean string, int position) {
ToastUtil.toastShort("单选点击了" + position);
//todo发送消息
......@@ -93,7 +94,7 @@ public class MsgViewHolderLingxiWhichQuestion extends MsgViewHolderBase implemen
}
@Override
public void onMultipleItemClick(@NotNull LingxiWhichQuestionBean string, int position) {
public void onMultipleItemClick(@NotNull QuestionItemBean string, int position) {
ToastUtil.toastShort("多选点击了" + position);
//多选发送消息
......
......@@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.TextView
import com.yidianling.im.R
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
import com.yidianling.im.session.viewholder.bean.QuestionItemBean
/**
* @author huozhiliang
......@@ -16,7 +17,7 @@ import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
* @date 2021/6/21
*/
class AdapterLingxiMultipleChoice : RecyclerView.Adapter<AdapterLingxiMultipleChoice.ViewHolder>() {
private lateinit var tagList:List<String>
private lateinit var tagList: List<String>
private var onItemClickListener: OnMultiplelItemClickListener? = null
class ViewHolder(itemView: View) :
......@@ -35,25 +36,32 @@ class AdapterLingxiMultipleChoice : RecyclerView.Adapter<AdapterLingxiMultipleCh
}
override fun getItemCount(): Int {
return tagList.size?:0
return tagList.size ?: 0
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// holder.tv_which_question.setText("")
holder.tv_which_question.setOnClickListener {
onItemClickListener?.onMultipleItemClick(
LingxiWhichQuestionBean(
true,
"aa",
"aaa"
),position)
}
// holder.tv_which_question.setOnClickListener {
// onItemClickListener?.onMultipleItemClick(
// LingxiWhichQuestionBean(
// isSelected = true,
// xquestionPaperId = "0",
// xquestionPaperName = "l",
// questionId = "1",
// questionTitle = "1",
// selectType = "1",
// selectVals = listOf<QuestionItemBean>(QuestionItemBean(id = "1",name = "2"))
// ), position
// )
// }
}
fun setTagData(data: List<String>) {
tagList = data
notifyDataSetChanged()
}
interface OnMultiplelItemClickListener {
fun onMultipleItemClick(string: LingxiWhichQuestionBean, position: Int)
fun onMultipleItemClick(string: QuestionItemBean, position: Int)
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.TextView
import com.yidianling.im.R
import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
import com.yidianling.im.session.viewholder.bean.QuestionItemBean
/**
* @author huozhiliang
......@@ -16,12 +17,12 @@ import com.yidianling.im.session.viewholder.bean.LingxiWhichQuestionBean
* @date 2021/6/21
*/
class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuestion.ViewHolder>() {
private lateinit var tagList:List<String>
private lateinit var tagList:List<QuestionItemBean>
private var onItemClickListener: OnQuestionlItemClickListener? = null
class ViewHolder(itemView: View) :
RecyclerView.ViewHolder(itemView) {
val tv_which_question: TextView = itemView.findViewById(R.id.tv_which_question)
val tvWhichQuestion: TextView = itemView.findViewById(R.id.tv_which_question)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
......@@ -39,21 +40,20 @@ class AdapterLingxiWhichQuestion : RecyclerView.Adapter<AdapterLingxiWhichQuesti
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// holder.tv_which_question.setText("")
holder.tv_which_question.setOnClickListener {
holder.tvWhichQuestion.text = tagList[position].name
holder.tvWhichQuestion.setOnClickListener {
onItemClickListener?.onItemClick(
LingxiWhichQuestionBean(
true,
"aa",
"aaa"
),position)
tagList[position],position)
}
}
fun setTagData(data: List<String>) {
fun setTagData(data: List<QuestionItemBean>) {
tagList = data
notifyDataSetChanged()
}
interface OnQuestionlItemClickListener {
fun onItemClick(string: LingxiWhichQuestionBean, position: Int)
fun onItemClick(string: QuestionItemBean, position: Int)
}
fun setItemListener(listener: OnQuestionlItemClickListener) {
this.onItemClickListener = listener
}
}
\ No newline at end of file
package com.yidianling.im.session.viewholder.bean
data class LingxiWhichQuestionBean (
var isSelected:Boolean,
var name:String,
var id:String
import com.google.gson.annotations.SerializedName
data class LingxiWhichQuestionBean(
var isSelected: Boolean,
var xquestionPaperId: String?,//试卷ID
var xquestionPaperName: String?,//试卷名称
var questionId:String?,//问题ID
var questionTitle:String?,//问题题目
var selectType:String?,//试卷type 1单选 2多选
var selectVals:ArrayList<QuestionItemBean>?//选项
)
data class QuestionItemBean(
var id:String?,
var name:String?
)
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="260dp"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
......
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