Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
fe422d1a
Commit
fe422d1a
authored
Jun 25, 2021
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:键盘事件处理
parent
1f960adc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
5 deletions
+48
-5
QuestionInformationView.kt
m-im/src/main/java/com/yidianling/uikit/business/session/view/QuestionInformationView.kt
+48
-5
No files found.
m-im/src/main/java/com/yidianling/uikit/business/session/view/QuestionInformationView.kt
View file @
fe422d1a
...
...
@@ -8,6 +8,7 @@ import android.os.Handler
import
android.text.Editable
import
android.text.TextUtils
import
android.text.TextWatcher
import
android.view.MotionEvent
import
android.view.View
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
...
...
@@ -114,7 +115,7 @@ class QuestionInformationView(
cl_input
.
visibility
=
VISIBLE
tv_problem
.
visibility
=
GONE
hsv_problem_tips
.
visibility
=
VISIBLE
et_input_problem
.
hint
=
"请简单描述遇到的问题……\n\n\n"
et_input_problem
.
hint
=
"请简单描述遇到的问题……\n\n\n"
// 打开软件盘
showInputMethod
(
et_input_problem
)
// 滚动到底部
...
...
@@ -157,7 +158,7 @@ class QuestionInformationView(
if
(
questionsBean
!=
null
)
{
//还有下一题
questionMultiItem2
.
questionsBean
=
questionsBean
if
(
"radio"
==
questionsBean
?
.
type
)
{
if
(
"radio"
==
questionsBean
.
type
)
{
questionMultiItem2
.
viewType
=
3
}
else
{
questionMultiItem2
.
viewType
=
4
...
...
@@ -178,7 +179,7 @@ class QuestionInformationView(
cl_input
.
visibility
=
VISIBLE
tv_problem
.
visibility
=
GONE
hsv_problem_tips
.
visibility
=
VISIBLE
et_input_problem
.
hint
=
"请简单描述遇到的问题……\n\n\n"
et_input_problem
.
hint
=
"请简单描述遇到的问题……\n\n\n"
// 打开软件盘
showInputMethod
(
et_input_problem
)
// 滚动到底部
...
...
@@ -199,10 +200,10 @@ class QuestionInformationView(
hsv_problem_tips
.
visibility
=
GONE
var
problem
=
"已选:"
list
?.
forEach
{
problem
+=
"# "
+
it
?.
name
problem
+=
"# "
+
it
?.
name
}
tv_problem
.
text
=
problem
et_input_problem
.
hint
=
"请输入其他事件......"
et_input_problem
.
hint
=
"请输入其他事件......"
// 打开软件盘
showInputMethod
(
et_input_problem
)
// 滚动到底部
...
...
@@ -215,6 +216,7 @@ class QuestionInformationView(
}
@SuppressLint
(
"ClickableViewAccessibility"
)
@RequiresApi
(
Build
.
VERSION_CODES
.
N
)
fun
setData
(
questionInfo
:
QuestionsInfoBean
)
{
mQuestionBean
=
questionInfo
...
...
@@ -306,6 +308,25 @@ class QuestionInformationView(
override
fun
keyBoardHide
(
height
:
Int
)
{
}
})
recycle
.
setOnTouchListener
{
_
:
View
?,
event
:
MotionEvent
->
when
(
event
.
action
)
{
MotionEvent
.
ACTION_DOWN
->
{
// 手势按下空白处的时候检测软件盘是否弹出
if
(
isShouldHideInput
(
et_input_problem
,
event
))
{
hideInputMethod
(
et_input_problem
)
}
true
}
MotionEvent
.
ACTION_CANCEL
,
MotionEvent
.
ACTION_UP
->
{
false
}
else
->
{
false
}
}
}
}
...
...
@@ -341,4 +362,25 @@ class QuestionInformationView(
dialog
!!
.
show
()
}
}
/**
* 判断软键盘是否需要隐藏
* @param v
* @param event
* @return
*/
private
fun
isShouldHideInput
(
v
:
View
?,
event
:
MotionEvent
):
Boolean
{
if
(
v
!=
null
&&
v
is
EditText
)
{
val
leftTop
=
intArrayOf
(
0
,
0
)
//获取输入框当前的location位置
v
.
getLocationInWindow
(
leftTop
)
val
left
=
leftTop
[
0
]
val
top
=
leftTop
[
1
]
val
bottom
=
top
+
v
.
getHeight
()
val
right
=
left
+
v
.
getWidth
()
return
!(
event
.
x
>
left
&&
event
.
x
<
right
&&
event
.
y
>
top
&&
event
.
y
<
bottom
)
}
return
false
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment