소스 검색

1.添加测评module

王鹏鹏 2 년 전
부모
커밋
1b77b43c3f

+ 63 - 5
evaluation/src/main/java/com/yingyangfly/evaluation/questionlist/QuestionListActivity.kt

@@ -1,10 +1,16 @@
 package com.yingyangfly.evaluation.questionlist
 
+import android.annotation.SuppressLint
 import android.view.MotionEvent
 import android.view.View
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.yingyangfly.baselib.base.BaseActivity
+import com.yingyangfly.baselib.dialog.TipsDialog
+import com.yingyangfly.baselib.ext.getEndAnimation
+import com.yingyangfly.baselib.ext.getScaleAnimation
 import com.yingyangfly.baselib.router.RouterUrlCommon
+import com.yingyangfly.baselib.utils.RxTimer
+import com.yingyangfly.evaluation.R
 import com.yingyangfly.evaluation.databinding.ActivityQuestionListBinding
 
 /**
@@ -13,21 +19,73 @@ import com.yingyangfly.evaluation.databinding.ActivityQuestionListBinding
 @Route(path = RouterUrlCommon.questionList)
 class QuestionListActivity : BaseActivity<ActivityQuestionListBinding>(), View.OnTouchListener {
 
-    override fun initViews() {
+    private lateinit var rxTimer: RxTimer
+    private var time: Long = 0
 
+    override fun initViews() {
+        rxTimer = RxTimer()
     }
 
+    @SuppressLint("ClickableViewAccessibility")
     override fun initListener() {
-
+        binding {
+            layoutHead.setOnTouchListener(this@QuestionListActivity)
+        }
     }
 
     override fun initData() {
-
+        val m: Long = 1000
+        rxTimer.interval(m) {
+            time = it + 1
+            val minutes = time / 60
+            val seconds = time % 60
+            binding.tvTimes.text = if (minutes > 0) {
+                "已用时 $minutes 分 $seconds 秒"
+            } else {
+                "已用时 $seconds 秒"
+            }
+        }
     }
 
+    @SuppressLint("ClickableViewAccessibility")
     override fun onTouch(v: View, event: MotionEvent): Boolean {
-        TODO("Not yet implemented")
-    }
+        when (event.action) {
+            MotionEvent.ACTION_DOWN -> {
+                if (v.id == R.id.layoutHead) {
+                    v.startAnimation(getScaleAnimation())
+                }
+            }
+
+            MotionEvent.ACTION_UP -> {
+                v.startAnimation(getEndAnimation())
+                if (v.id == R.id.layoutHead) {
+                    showTipsDialog()
+                }
+            }
 
+            MotionEvent.ACTION_CANCEL -> {
+                if (v.id == R.id.layoutHead) {
+                    v.startAnimation(getEndAnimation())
+                }
+            }
+        }
+        return true
+    }
 
+    /**
+     * 退出确认弹窗
+     */
+    private fun showTipsDialog() {
+        TipsDialog.TipDialogBuilder()
+            .title("提示")
+            .content("您确定取消测评?")
+            .leftBtnText("取消")
+            .rightBtnText("确定")
+            .leftClick({
+            }, true)
+            .rightClick({
+                finish()
+            }, true)
+            .show(supportFragmentManager)
+    }
 }

+ 54 - 2
evaluation/src/main/res/layout/activity_question_list.xml

@@ -1,13 +1,65 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     tools:ignore="ResourceName">
 
     <androidx.constraintlayout.widget.ConstraintLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        style="@style/layout_properties_specify_width_geight"
+        android:background="@mipmap/icon_uniform_background">
 
+        <LinearLayout
+            android:id="@+id/layoutHead"
+            style="@style/back_layout"
+            tools:ignore="MissingConstraints">
 
+            <androidx.appcompat.widget.AppCompatImageView style="@style/back_image" />
+
+            <androidx.appcompat.widget.AppCompatTextView style="@style/back_text" />
+        </LinearLayout>
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_32px"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_34px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTimes"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_36px"
+            android:layout_marginEnd="@dimen/divider_30px"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_28px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.cardview.widget.CardView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_margin="@dimen/divider_18px"
+            app:cardBackgroundColor="@android:color/white"
+            app:cardCornerRadius="@dimen/divider_38px"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvTitle">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
+        </androidx.cardview.widget.CardView>
     </androidx.constraintlayout.widget.ConstraintLayout>
 
 </layout>

+ 0 - 1
mmse/src/main/java/com/yingyangfly/mmse/activity/QuestionsActivity.kt

@@ -114,7 +114,6 @@ class QuestionsActivity : BaseMVVMActivity<ActivityQuestionsBinding, QuestionsVi
                 }
             }
         }
-        RxBusCodes
         return true
     }