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
58ad4489
Commit
58ad4489
authored
Jun 24, 2021
by
YKai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:代码提交
parent
e65e3fce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
13 deletions
+103
-13
SoftKeyBoardListener.java
m-im/src/main/java/com/yidianling/listener/SoftKeyBoardListener.java
+69
-0
CollectInfoPopupWindow.kt
m-im/src/main/java/com/yidianling/uikit/business/session/view/CollectInfoPopupWindow.kt
+5
-5
QuestionInformationView.kt
m-im/src/main/java/com/yidianling/uikit/business/session/view/QuestionInformationView.kt
+29
-8
No files found.
m-im/src/main/java/com/yidianling/listener/SoftKeyBoardListener.java
0 → 100644
View file @
58ad4489
package
com
.
yidianling
.
listener
;
import
android.app.Activity
;
import
android.graphics.Rect
;
import
android.view.View
;
/**
* Created by Ykai on 2020/9/11.
*
* 键盘打开关闭监听类
*/
public
class
SoftKeyBoardListener
{
private
View
rootView
;
//activity的根视图
int
rootViewVisibleHeight
;
//纪录根视图的显示高度
private
OnSoftKeyBoardChangeListener
onSoftKeyBoardChangeListener
;
public
SoftKeyBoardListener
(
Activity
activity
)
{
//获取activity的根视图
rootView
=
activity
.
getWindow
().
getDecorView
();
//监听视图树中全局布局发生改变或者视图树中的某个视图的可视状态发生改变
rootView
.
getViewTreeObserver
().
addOnGlobalLayoutListener
(()
->
{
//获取当前根视图在屏幕上显示的大小
Rect
r
=
new
Rect
();
rootView
.
getWindowVisibleDisplayFrame
(
r
);
int
visibleHeight
=
r
.
height
();
System
.
out
.
println
(
""
+
visibleHeight
);
if
(
rootViewVisibleHeight
==
0
)
{
rootViewVisibleHeight
=
visibleHeight
;
return
;
}
//根视图显示高度没有变化,可以看作软键盘显示/隐藏状态没有改变
if
(
rootViewVisibleHeight
==
visibleHeight
)
{
return
;
}
//根视图显示高度变小超过200,可以看作软键盘显示了
if
(
rootViewVisibleHeight
-
visibleHeight
>
200
)
{
if
(
onSoftKeyBoardChangeListener
!=
null
)
{
onSoftKeyBoardChangeListener
.
keyBoardShow
(
rootViewVisibleHeight
-
visibleHeight
);
}
rootViewVisibleHeight
=
visibleHeight
;
return
;
}
//根视图显示高度变大超过200,可以看作软键盘隐藏了
if
(
visibleHeight
-
rootViewVisibleHeight
>
200
)
{
if
(
onSoftKeyBoardChangeListener
!=
null
)
{
onSoftKeyBoardChangeListener
.
keyBoardHide
(
visibleHeight
-
rootViewVisibleHeight
);
}
rootViewVisibleHeight
=
visibleHeight
;
}
});
}
private
void
setOnSoftKeyBoardChangeListener
(
OnSoftKeyBoardChangeListener
onSoftKeyBoardChangeListener
)
{
this
.
onSoftKeyBoardChangeListener
=
onSoftKeyBoardChangeListener
;
}
public
interface
OnSoftKeyBoardChangeListener
{
void
keyBoardShow
(
int
height
);
void
keyBoardHide
(
int
height
);
}
public
static
void
setListener
(
Activity
activity
,
OnSoftKeyBoardChangeListener
onSoftKeyBoardChangeListener
)
{
SoftKeyBoardListener
softKeyBoardListener
=
new
SoftKeyBoardListener
(
activity
);
softKeyBoardListener
.
setOnSoftKeyBoardChangeListener
(
onSoftKeyBoardChangeListener
);
}
}
m-im/src/main/java/com/yidianling/uikit/business/session/view/CollectInfoPopupWindow.kt
View file @
58ad4489
package
com.yidianling.uikit.business.session.view
import
android.app.Activity
import
android.content.Context
import
android.graphics.drawable.BitmapDrawable
import
android.os.Build
import
android.view.Gravity
import
android.view.KeyEvent
import
android.view.View
import
android.view.ViewGroup
import
android.widget.PopupWindow
import
androidx.annotation.RequiresApi
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean
...
...
@@ -18,7 +21,7 @@ import com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean
* @Company 壹点灵
* @date 2019/12/10
*/
class
CollectInfoPopupWindow
(
var
mContext
:
Context
,
var
listener
:
OnSendMsgListener
)
:
class
CollectInfoPopupWindow
(
var
mContext
:
Activity
,
var
listener
:
OnSendMsgListener
)
:
PopupWindow
(
mContext
)
{
private
var
collectUserInformationView
:
QuestionInformationView
private
var
isFromBack
=
true
...
...
@@ -53,11 +56,8 @@ class CollectInfoPopupWindow(var mContext: Context, var listener: OnSendMsgListe
isOutsideTouchable
=
false
}
@RequiresApi
(
Build
.
VERSION_CODES
.
N
)
fun
setData
(
questionInfo
:
QuestionsInfoBean
)
{
if
(
questionInfo
==
null
)
{
ToastUtil
.
toastShort
(
"数据异常,请稍后重试"
)
return
}
collectUserInformationView
.
setData
(
questionInfo
)
}
...
...
m-im/src/main/java/com/yidianling/uikit/business/session/view/QuestionInformationView.kt
View file @
58ad4489
package
com.yidianling.uikit.business.session.view
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.os.Build
import
android.os.Handler
import
android.view.View
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
...
...
@@ -13,8 +15,11 @@ import androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.view.dialog.CommonDialog
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxKeyboardTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.R
import
com.yidianling.listener.SoftKeyBoardListener
import
com.yidianling.uikit.business.session.view.question.QuestionAdapter
import
com.yidianling.uikit.business.session.view.question.QuestionMultiItem
import
com.yidianling.uikit.business.session.view.question.QuestionOneCheckListener
...
...
@@ -34,7 +39,7 @@ import kotlin.collections.ArrayList
*/
@SuppressLint
(
"ViewConstructor"
)
class
QuestionInformationView
(
var
mContext
:
Context
,
var
mContext
:
Activity
,
var
skipEvent
:
()
->
Unit
,
var
backEvent
:
()
->
Unit
,
var
sendMsgEvent
:
(
content
:
String
,
list
:
List
<
QuestionsInfoBean
>)
->
Unit
...
...
@@ -83,7 +88,7 @@ class QuestionInformationView(
//使用下一题nextQuestionId 取到题
val
questionsBean
=
mQuestionBean
!!
.
questions
[
nextQuestionId
]
if
(
questionsBean
!=
null
)
{
if
(
questionsBean
!=
null
)
{
//还有下一题
questionMultiItem2
.
questionsBean
=
questionsBean
if
(
"radio"
==
questionsBean
?.
type
)
{
...
...
@@ -92,7 +97,7 @@ class QuestionInformationView(
questionMultiItem2
.
viewType
=
4
}
mData
.
add
(
questionMultiItem2
)
}
else
{
}
else
{
//没有下一题了
}
...
...
@@ -105,12 +110,20 @@ class QuestionInformationView(
}
override
fun
showOtherEdit
(
list
:
List
<
OptionsBean
?>?)
{
// 滚动到底部
recycle
.
smoothScrollToPosition
(
mData
.
size
-
1
)
//弹出输入框
//显示输入框
cl_input
.
visibility
=
VISIBLE
tv_problem
.
visibility
=
VISIBLE
var
problem
=
"已选:"
list
?.
forEach
{
problem
+=
"# "
+
it
?.
name
}
tv_problem
.
text
=
problem
// 打开软件盘
showInputMethod
(
et_input_problem
)
// 滚动到底部
Handler
().
postDelayed
({
recycle
.
scrollToPosition
(
mData
.
size
-
1
)
},
500L
)
}
})
...
...
@@ -142,8 +155,16 @@ class QuestionInformationView(
}
}
// 监听键盘状态
SoftKeyBoardListener
.
setListener
(
mContext
,
object
:
SoftKeyBoardListener
.
OnSoftKeyBoardChangeListener
{
override
fun
keyBoardShow
(
height
:
Int
)
{
recycle
.
smoothScrollToPosition
(
mData
.
size
-
1
)
}
// mQuestionAdapter.notifyDataSetChanged()
override
fun
keyBoardHide
(
height
:
Int
)
{
}
})
}
...
...
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