Commit 1f960adc by YKai

feat:代码提交

parent d6ce4af1
......@@ -18,9 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.listener.SoftKeyBoardListener
import com.yidianling.uikit.business.session.view.question.QuestionAdapter
......@@ -49,7 +46,7 @@ class QuestionInformationView(
) : LinearLayout(mContext) {
private var dialog: CommonDialog? = null
private lateinit var mQuestionAdapter: QuestionAdapter
private var mQuestionAdapter: QuestionAdapter
private var mData = ArrayList<QuestionMultiItem>();
private var mQuestionBean: QuestionsInfoBean? = null
private var problemContent = ""
......@@ -78,20 +75,21 @@ class QuestionInformationView(
recycle.adapter = mQuestionAdapter
mQuestionAdapter.setOneCheckListener(object : QuestionOneCheckListener {
override fun itemClick(bean: OptionsBean?, questionId: String) {
val questionMultiItem = QuestionMultiItem()
questionMultiItem.type2Text = bean?.name
questionMultiItem.viewType = 2
mData.add(questionMultiItem)
mQuestionAdapter.notifyDataSetChanged()
recycle.scrollToPosition(mData.size - 1)
val questionMultiItem2 = QuestionMultiItem()
// 使用问题questionId 去questionChains取到选项配置
val options = mQuestionBean!!.questionChains[questionId]?.options
val options = mQuestionBean!!.questionPaper.questionChains[questionId]?.options
//从配置里找到下一题id
val nextQuestionId = options?.get(bean?.id)
//使用下一题nextQuestionId 取到题
val questionsBean = mQuestionBean!!.questions[nextQuestionId]
val questionsBean = mQuestionBean!!.questionPaper.questions[nextQuestionId]
if (questionsBean != null) {
//还有下一题
questionMultiItem2.questionsBean = questionsBean
......@@ -99,21 +97,102 @@ class QuestionInformationView(
questionMultiItem2.viewType = 3
} else {
questionMultiItem2.viewType = 4
questionMultiItem2.type4CanClick = true
}
mData.add(questionMultiItem2)
} else {
//没有下一题了
//没有下一题了,展示描述=题
for ((index, item) in mData.withIndex()) {
mData[index].type4CanClick = false
}
val questionMultiItem5 = QuestionMultiItem()
questionMultiItem5.type5Bean = mQuestionBean!!.questions[1]
questionMultiItem5.viewType = 5
mData.add(questionMultiItem5)
//显示输入框
cl_input.visibility = VISIBLE
tv_problem.visibility = GONE
hsv_problem_tips.visibility = VISIBLE
et_input_problem.hint="请简单描述遇到的问题……\n\n\n"
// 打开软件盘
showInputMethod(et_input_problem)
// 滚动到底部
Handler().postDelayed({
recycle.scrollToPosition(mData.size - 1)
}, 500L)
}
mQuestionAdapter.notifyDataSetChanged()
recycle.scrollToPosition(mData.size - 1)
}
override fun moreDefineItemClick(list: List<OptionsBean?>?) {
override fun moreDefineItemClick(list: List<OptionsBean?>?, questionId: String) {
//多选确定
var anwserStr = ""
list?.forEach {
if (anwserStr.isNotEmpty()) {
anwserStr = anwserStr + "、" + it?.name
} else {
anwserStr += it?.name
}
}
val bean = list?.get(0)
val questionMultiItem = QuestionMultiItem()
questionMultiItem.type2Text = anwserStr
questionMultiItem.viewType = 2
mData.add(questionMultiItem)
mQuestionAdapter.notifyDataSetChanged()
recycle.scrollToPosition(mData.size - 1)
val questionMultiItem2 = QuestionMultiItem()
// 使用问题questionId 去questionChains取到选项配置
val options = mQuestionBean!!.questionPaper.questionChains[questionId]?.options
//从配置里找到下一题id
val nextQuestionId = options?.get(bean?.id)
//使用下一题nextQuestionId 取到题
val questionsBean = mQuestionBean!!.questionPaper.questions[nextQuestionId]
if (questionsBean != null) {
//还有下一题
questionMultiItem2.questionsBean = questionsBean
if ("radio" == questionsBean?.type) {
questionMultiItem2.viewType = 3
} else {
questionMultiItem2.viewType = 4
questionMultiItem2.type4CanClick = true
}
mData.add(questionMultiItem2)
} else {
//没有下一题了,展示描述=题
for ((index, item) in mData.withIndex()) {
mData[index].type4CanClick = false
}
val questionMultiItem5 = QuestionMultiItem()
questionMultiItem5.type5Bean = mQuestionBean!!.questions[1]
questionMultiItem5.viewType = 5
mData.add(questionMultiItem5)
//显示输入框
cl_input.visibility = VISIBLE
tv_problem.visibility = GONE
hsv_problem_tips.visibility = VISIBLE
et_input_problem.hint="请简单描述遇到的问题……\n\n\n"
// 打开软件盘
showInputMethod(et_input_problem)
// 滚动到底部
Handler().postDelayed({
recycle.scrollToPosition(mData.size - 1)
}, 500L)
}
mQuestionAdapter.notifyDataSetChanged()
recycle.scrollToPosition(mData.size - 1)
}
override fun showOtherEdit(list: List<OptionsBean?>?) {
override fun showOtherEdit(list: List<OptionsBean?>?, questionId: String) {
//显示输入框
cl_input.visibility = VISIBLE
tv_problem.visibility = VISIBLE
......@@ -141,20 +220,21 @@ class QuestionInformationView(
mQuestionBean = questionInfo
mData.clear()
val questionMultiItem = QuestionMultiItem()
questionMultiItem.type1Text = questionInfo.name
questionMultiItem.type1Text = questionInfo.questions[0].question
questionMultiItem.viewType = 1
mData.add(questionMultiItem)
val questionMultiItem2 = QuestionMultiItem()
mQuestionBean!!.questionChains.forEach { (k, v) ->
mQuestionBean!!.questionPaper.questionChains.forEach { (k, v) ->
if (v.head) {
// 代表第一题 ,使用questionId 去questions取到对应的提
val questionsBean = mQuestionBean!!.questions[v.questionId]
val questionsBean = mQuestionBean!!.questionPaper.questions[v.questionId]
questionMultiItem2.questionsBean = questionsBean
if ("radio" == questionsBean?.type) {
questionMultiItem2.viewType = 3
} else {
questionMultiItem2.viewType = 4
questionMultiItem2.type4CanClick = true
}
mData.add(questionMultiItem2)
return@forEach
......@@ -163,6 +243,8 @@ class QuestionInformationView(
tv_send.setOnClickListener {
et_input_problem.setText("")
hideInputMethod(et_input_problem)
//隐藏输入框
cl_input.visibility = GONE
}
tv_cur_problem.setOnClickListener {
problemContent = et_input_problem.text.toString()
......@@ -185,7 +267,7 @@ class QuestionInformationView(
et_input_problem.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(p0: Editable?) {
// 动态监听输入行数大于等于4行,滚动列表到底部
if (et_input_problem.lineCount >= 4 && recycle.canScrollVertically(1)) {
if (et_input_problem.lineCount >= 3 && recycle.canScrollVertically(1)) {
recycle.smoothScrollToPosition(mData.size - 1)
}
}
......@@ -218,6 +300,7 @@ class QuestionInformationView(
object : SoftKeyBoardListener.OnSoftKeyBoardChangeListener {
override fun keyBoardShow(height: Int) {
recycle.smoothScrollToPosition(mData.size - 1)
recycle.scrollToPosition(mData.size - 1)
}
override fun keyBoardHide(height: Int) {
......
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