Commit 4afc573b by YKai

feat:代码提交

parent 58ad4489
...@@ -5,6 +5,9 @@ import android.app.Activity ...@@ -5,6 +5,9 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
...@@ -49,6 +52,7 @@ class QuestionInformationView( ...@@ -49,6 +52,7 @@ class QuestionInformationView(
private lateinit var mQuestionAdapter: QuestionAdapter private lateinit var mQuestionAdapter: QuestionAdapter
private var mData = ArrayList<QuestionMultiItem>(); private var mData = ArrayList<QuestionMultiItem>();
private var mQuestionBean: QuestionsInfoBean? = null private var mQuestionBean: QuestionsInfoBean? = null
private var problemContent = ""
init { init {
val params = LayoutParams( val params = LayoutParams(
...@@ -113,11 +117,13 @@ class QuestionInformationView( ...@@ -113,11 +117,13 @@ class QuestionInformationView(
//显示输入框 //显示输入框
cl_input.visibility = VISIBLE cl_input.visibility = VISIBLE
tv_problem.visibility = VISIBLE tv_problem.visibility = VISIBLE
hsv_problem_tips.visibility = GONE
var problem = "已选:" var problem = "已选:"
list?.forEach { list?.forEach {
problem+="# "+it?.name problem+="# "+it?.name
} }
tv_problem.text = problem tv_problem.text = problem
et_input_problem.hint="请输入其他事件......"
// 打开软件盘 // 打开软件盘
showInputMethod(et_input_problem) showInputMethod(et_input_problem)
// 滚动到底部 // 滚动到底部
...@@ -154,7 +160,59 @@ class QuestionInformationView( ...@@ -154,7 +160,59 @@ class QuestionInformationView(
return@forEach return@forEach
} }
} }
tv_send.setOnClickListener {
et_input_problem.setText("")
hideInputMethod(et_input_problem)
}
tv_cur_problem.setOnClickListener {
problemContent = et_input_problem.text.toString()
et_input_problem.setText("$problemContent${tv_cur_problem.text}:\n")
et_input_problem.setSelection(et_input_problem.text.toString().length - 1)
recycle.smoothScrollToPosition(mData.size - 1)
}
tv_duration.setOnClickListener {
problemContent = et_input_problem.text.toString()
et_input_problem.setText("$problemContent\n${tv_duration.text}:\n")
et_input_problem.setSelection(et_input_problem.text.toString().length - 1)
recycle.smoothScrollToPosition(mData.size - 1)
}
tv_problem_impact.setOnClickListener {
problemContent = et_input_problem.text.toString()
et_input_problem.setText("$problemContent\n${tv_problem_impact.text}:\n")
et_input_problem.setSelection(et_input_problem.text.toString().length - 1)
recycle.smoothScrollToPosition(mData.size - 1)
}
et_input_problem.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(p0: Editable?) {
// 动态监听输入行数大于等于4行,滚动列表到底部
if (et_input_problem.lineCount >= 4 && recycle.canScrollVertically(1)) {
recycle.smoothScrollToPosition(mData.size - 1)
}
}
override fun beforeTextChanged(p0: CharSequence, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(char: CharSequence, p1: Int, p2: Int, p3: Int) {
if (char.isNotEmpty()) {
if (char.contains("\n")) {
val s = char.toString().replace("\n", "")
if (TextUtils.isEmpty(s)) {
tv_send.visibility = View.GONE
et_input_problem.setText("")
} else {
tv_send.visibility = View.VISIBLE
}
} else {
tv_send.visibility = View.VISIBLE
}
} else {
tv_send.visibility = View.GONE
}
}
})
// 监听键盘状态 // 监听键盘状态
SoftKeyBoardListener.setListener(mContext, SoftKeyBoardListener.setListener(mContext,
object : SoftKeyBoardListener.OnSoftKeyBoardChangeListener { object : SoftKeyBoardListener.OnSoftKeyBoardChangeListener {
...@@ -178,7 +236,6 @@ class QuestionInformationView( ...@@ -178,7 +236,6 @@ class QuestionInformationView(
// 显示键盘布局 // 显示键盘布局
private fun showInputMethod(editTextMessage: EditText) { private fun showInputMethod(editTextMessage: EditText) {
editTextMessage.requestFocus() editTextMessage.requestFocus()
val imm = mContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager val imm = mContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(editTextMessage, 0) imm.showSoftInput(editTextMessage, 0)
} }
......
...@@ -57,18 +57,19 @@ ...@@ -57,18 +57,19 @@
android:id="@+id/recycle" android:id="@+id/recycle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@color/platform_color_F0F0F0" android:background="@color/color_f8f8f8"
app:layout_constraintBottom_toTopOf="@id/cl_input" app:layout_constraintBottom_toTopOf="@id/cl_input"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:paddingBottom="50dp"
app:layout_constraintVertical_weight="1" /> app:layout_constraintVertical_weight="1" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_input" android:id="@+id/cl_input"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent">
<TextView <TextView
...@@ -80,17 +81,19 @@ ...@@ -80,17 +81,19 @@
android:textColor="@color/color_242424" android:textColor="@color/color_242424"
android:textSize="14sp" android:textSize="14sp"
android:visibility="gone" android:visibility="gone"
android:background="@color/color_f8f8f8"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible"
tools:text="已选:" /> tools:text="已选:" />
<EditText <EditText
android:id="@+id/et_input_problem" android:id="@+id/et_input_problem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null"
android:gravity="top" android:gravity="top"
android:hint="请简单描述遇到的问题......" android:hint="请简单描述遇到的问题......"
android:background="@color/white"
android:maxHeight="200dp" android:maxHeight="200dp"
android:padding="12dp" android:padding="12dp"
android:textColor="@color/color_242424" android:textColor="@color/color_242424"
...@@ -104,6 +107,7 @@ ...@@ -104,6 +107,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="69dp" android:layout_marginEnd="69dp"
android:layout_marginBottom="14dp" android:layout_marginBottom="14dp"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/et_input_problem"> app:layout_constraintTop_toBottomOf="@id/et_input_problem">
......
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