|
|
@@ -9,6 +9,7 @@ import com.yingyang.mmse.databinding.FragmentInputBinding
|
|
|
import com.yingyangfly.baselib.base.BaseFragment
|
|
|
import com.yingyangfly.baselib.db.QuestionsBean
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.mmse.adapter.NumberAdapter
|
|
|
|
|
|
/**
|
|
|
@@ -49,6 +50,30 @@ class InputFragment : BaseFragment<FragmentInputBinding>() {
|
|
|
binding.rvNum.layoutManager = GridLayoutManager(mContext, 3)
|
|
|
binding.rvNum.adapter = numberAdapter
|
|
|
numberAdapter.setData(numberList)
|
|
|
+ numberAdapter.onNumClickListener = { bean, type ->
|
|
|
+ when (type) {
|
|
|
+ "0" -> {
|
|
|
+ stringBuffer.append(bean)
|
|
|
+ binding.tvYear.text = stringBuffer.toString()
|
|
|
+
|
|
|
+ }
|
|
|
+ "1" -> {
|
|
|
+ if (stringBuffer.toString().isNullOrEmpty().not()) {
|
|
|
+ val size = stringBuffer.toString().length - 1
|
|
|
+ stringBuffer.deleteCharAt(size)
|
|
|
+ binding.tvYear.text = stringBuffer.toString()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ "2" -> {
|
|
|
+ if (dao != null) {
|
|
|
+ if (question != null) {
|
|
|
+ question!!.inputString = stringBuffer.toString()
|
|
|
+ dao?.update(question!!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun initListener() {
|
|
|
@@ -66,13 +91,22 @@ class InputFragment : BaseFragment<FragmentInputBinding>() {
|
|
|
}
|
|
|
//下一页
|
|
|
btnNext.setOnSingleClickListener { view ->
|
|
|
- nextQuestionId++
|
|
|
- if (nextQuestionId < 6) {
|
|
|
- loadData()
|
|
|
+ if (binding.tvYear.text.toString().isNullOrEmpty()) {
|
|
|
+ val str = "请输入" + question!!.reviewItem
|
|
|
+ str.toast()
|
|
|
} else {
|
|
|
- val bundle = bundleOf("questionId" to nextQuestionId)
|
|
|
- val controller = Navigation.findNavController(view)
|
|
|
- controller.navigate(R.id.action_inputFragment_to_judgmentFragment, bundle)
|
|
|
+ if (question != null) {
|
|
|
+ question!!.inputString = stringBuffer.toString()
|
|
|
+ dao?.update(question!!)
|
|
|
+ }
|
|
|
+ nextQuestionId++
|
|
|
+ if (nextQuestionId < 6) {
|
|
|
+ loadData()
|
|
|
+ } else {
|
|
|
+ val bundle = bundleOf("questionId" to nextQuestionId)
|
|
|
+ val controller = Navigation.findNavController(view)
|
|
|
+ controller.navigate(R.id.action_inputFragment_to_judgmentFragment, bundle)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -92,6 +126,10 @@ class InputFragment : BaseFragment<FragmentInputBinding>() {
|
|
|
*/
|
|
|
private fun loadData() {
|
|
|
if (dao != null) {
|
|
|
+ if (stringBuffer.toString().isNullOrEmpty().not()) {
|
|
|
+ val length = stringBuffer.length
|
|
|
+ stringBuffer.delete(0, length)
|
|
|
+ }
|
|
|
question = dao?.getQuestion(nextQuestionId)
|
|
|
if (question != null) {
|
|
|
binding.data = question
|