|
@@ -1,41 +1,77 @@
|
|
|
package com.yingyangfly.evaluation.otherevaluation
|
|
package com.yingyangfly.evaluation.otherevaluation
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
|
|
+import android.text.TextUtils
|
|
|
|
|
+import android.view.MotionEvent
|
|
|
|
|
+import android.view.View
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
|
|
+import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
|
|
+import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
|
|
+import com.yingyangfly.evaluation.R
|
|
|
import com.yingyangfly.evaluation.adapter.EvaluationTypeAdapter
|
|
import com.yingyangfly.evaluation.adapter.EvaluationTypeAdapter
|
|
|
|
|
+import com.yingyangfly.evaluation.adapter.ExaminationAdapter
|
|
|
import com.yingyangfly.evaluation.databinding.ActivityOtherEvaluationBinding
|
|
import com.yingyangfly.evaluation.databinding.ActivityOtherEvaluationBinding
|
|
|
import com.yingyangfly.evaluation.entity.EvaluationTypeBean
|
|
import com.yingyangfly.evaluation.entity.EvaluationTypeBean
|
|
|
|
|
+import com.yingyangfly.evaluation.entity.ExaminationRecord
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 其他测评功能页面
|
|
* 其他测评功能页面
|
|
|
*/
|
|
*/
|
|
|
@Route(path = RouterUrlCommon.otherEvaluation)
|
|
@Route(path = RouterUrlCommon.otherEvaluation)
|
|
|
class OtherEvaluationActivity :
|
|
class OtherEvaluationActivity :
|
|
|
- BaseMVVMActivity<ActivityOtherEvaluationBinding, OtherEvaluationViewModel>() {
|
|
|
|
|
|
|
+ BaseMVVMActivity<ActivityOtherEvaluationBinding, OtherEvaluationViewModel>(),
|
|
|
|
|
+ View.OnTouchListener {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 消息类型adapter
|
|
|
|
|
|
|
+ * 试题库类型adapter
|
|
|
*/
|
|
*/
|
|
|
private var evaluationType = ""
|
|
private var evaluationType = ""
|
|
|
private var evaluationTypeList = mutableListOf<EvaluationTypeBean>()
|
|
private var evaluationTypeList = mutableListOf<EvaluationTypeBean>()
|
|
|
private val evaluationAdapter by lazy { EvaluationTypeAdapter() }
|
|
private val evaluationAdapter by lazy { EvaluationTypeAdapter() }
|
|
|
|
|
|
|
|
|
|
+ private var page = 1
|
|
|
|
|
+ private var evaluationList = mutableListOf<ExaminationRecord>()
|
|
|
|
|
+ private val examinationAdapter by lazy { ExaminationAdapter() }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
override fun initViews() {
|
|
override fun initViews() {
|
|
|
binding {
|
|
binding {
|
|
|
|
|
+ swipeEvaluation.setEnableLoadMore(true)
|
|
|
|
|
+ swipeEvaluation.setEnableRefresh(true)
|
|
|
val layoutManager =
|
|
val layoutManager =
|
|
|
LinearLayoutManager(this@OtherEvaluationActivity, RecyclerView.HORIZONTAL, false)
|
|
LinearLayoutManager(this@OtherEvaluationActivity, RecyclerView.HORIZONTAL, false)
|
|
|
rvEvaluationType.layoutManager = layoutManager
|
|
rvEvaluationType.layoutManager = layoutManager
|
|
|
rvEvaluationType.adapter = evaluationAdapter
|
|
rvEvaluationType.adapter = evaluationAdapter
|
|
|
|
|
+ evaluationAdapter.onClickListener = {
|
|
|
|
|
+ evaluationType = it.dictValue
|
|
|
|
|
+ getExaminationList(true, true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ rvEvaluation.adapter = examinationAdapter
|
|
|
|
|
+ examinationAdapter.onClickListener = {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun initListener() {
|
|
override fun initListener() {
|
|
|
|
|
+ binding {
|
|
|
|
|
+ layoutHead.setOnTouchListener(this@OtherEvaluationActivity)
|
|
|
|
|
|
|
|
|
|
+ swipeEvaluation.setOnRefreshListener {
|
|
|
|
|
+ getExaminationList(true, false)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ swipeEvaluation.setOnLoadMoreListener {
|
|
|
|
|
+ getExaminationList(false, false)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun initData() {
|
|
override fun initData() {
|
|
@@ -50,7 +86,6 @@ class OtherEvaluationActivity :
|
|
|
/**
|
|
/**
|
|
|
* 获取试题类型
|
|
* 获取试题类型
|
|
|
*/
|
|
*/
|
|
|
- @SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
private fun getEvaluationType() {
|
|
private fun getEvaluationType() {
|
|
|
evaluationTypeList.clear()
|
|
evaluationTypeList.clear()
|
|
|
viewModel.getSelectByDictType(fail = {
|
|
viewModel.getSelectByDictType(fail = {
|
|
@@ -59,8 +94,67 @@ class OtherEvaluationActivity :
|
|
|
evaluationTypeList.clear()
|
|
evaluationTypeList.clear()
|
|
|
if (it.isNullOrEmpty().not()) {
|
|
if (it.isNullOrEmpty().not()) {
|
|
|
evaluationTypeList.addAll(it!!)
|
|
evaluationTypeList.addAll(it!!)
|
|
|
|
|
+ if (TextUtils.isEmpty(evaluationType)) {
|
|
|
|
|
+ evaluationType = it[0].dictValue
|
|
|
|
|
+ getExaminationList(true, true)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (TextUtils.isEmpty(evaluationType).not()) {
|
|
|
|
|
+ evaluationAdapter.setContent(evaluationType)
|
|
|
|
|
+ }
|
|
|
|
|
+ evaluationAdapter.setData(evaluationTypeList)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取试题库列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun getExaminationList(
|
|
|
|
|
+ isRefresh: Boolean, showLoading: Boolean
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (isRefresh) {
|
|
|
|
|
+ page = 1
|
|
|
|
|
+ binding.swipeEvaluation.resetNoMoreData()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ page++
|
|
|
|
|
+ }
|
|
|
|
|
+ viewModel.getExaminationList(showLoading, page, evaluationType, fail = {
|
|
|
|
|
+ it.toast()
|
|
|
|
|
+ }, success = {
|
|
|
|
|
+ if (isRefresh) {
|
|
|
|
|
+ evaluationList.clear()
|
|
|
}
|
|
}
|
|
|
- evaluationAdapter.notifyDataSetChanged()
|
|
|
|
|
|
|
+ if (it != null && it.records.isNullOrEmpty().not()) {
|
|
|
|
|
+ evaluationList.addAll(it.records)
|
|
|
|
|
+ }
|
|
|
|
|
+ examinationAdapter.setData(evaluationList)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
|
|
+ override fun onTouch(v: View, event: MotionEvent): Boolean {
|
|
|
|
|
+ when (event.action) {
|
|
|
|
|
+ MotionEvent.ACTION_DOWN -> {
|
|
|
|
|
+ if (v.id == R.id.layoutHead) {
|
|
|
|
|
+ v.startAnimation(getScaleAnimation())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MotionEvent.ACTION_UP -> {
|
|
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
|
|
+ when (v.id) {
|
|
|
|
|
+ R.id.layoutHead -> {
|
|
|
|
|
+ finish()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MotionEvent.ACTION_CANCEL -> {
|
|
|
|
|
+ if (v.id == R.id.layoutHead) {
|
|
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|