[feedback]优化软键盘弹出时,遮挡输入框
[feedback]11111
This commit is contained in:
@@ -255,12 +255,15 @@ private class GestureConflictFixer(private val ids: List<Int>) : RecyclerView.On
|
||||
private fun computeIntercepted(x: Int, y: Int, rv: RecyclerView, ids: List<Int>): Boolean {
|
||||
return ids.takeIf { it.isNotEmpty() }?.find {
|
||||
val out = Rect()
|
||||
rv.findViewById<View>(it)?.getGlobalVisibleRect(out)
|
||||
if (!out.isEmpty) {
|
||||
out.contains(x, y)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
val view = rv.findViewById<View>(it)
|
||||
view?.run {
|
||||
getGlobalVisibleRect(out)
|
||||
if (!out.isEmpty) {
|
||||
out.contains(x, y) and (canScrollVertically(-1) || canScrollVertically(1))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} ?: false
|
||||
}?.let { it != View.NO_ID } ?: false
|
||||
}
|
||||
|
||||
@@ -273,40 +276,16 @@ private class GestureConflictFixer(private val ids: List<Int>) : RecyclerView.On
|
||||
scrollState = newState
|
||||
if (oldState == RecyclerView.SCROLL_STATE_IDLE && newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
recyclerView.layoutManager?.let {
|
||||
if (intercpted) {
|
||||
recyclerView.stopScroll()
|
||||
val canScrollHorizontally = it.canScrollHorizontally()
|
||||
val canScrollVertically = it.canScrollVertically()
|
||||
if (canScrollHorizontally != canScrollVertically) {
|
||||
if (intercpted || (canScrollHorizontally && abs(dy) > abs(dx))
|
||||
|| (canScrollVertically && abs(dx) > abs(dy))) {
|
||||
recyclerView.stopScroll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.toast(text: CharSequence, duration: Long = 2, unit: TimeUnit = SECONDS) {
|
||||
val activity = (this as? FragmentActivity) ?: throw IllegalStateException("please use Activity to trigger toast show.")
|
||||
activity.lifeCycleScope.launchWhenResumed {
|
||||
val pop = PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also {
|
||||
it.isOutsideTouchable = false
|
||||
it.isTouchable = false
|
||||
it.isFocusable = false
|
||||
it.setBackgroundDrawable(shape(solid = Color.parseColor("#99000000"), radius = 32.PX))
|
||||
}
|
||||
val tv = TextView(this@toast)
|
||||
tv.setTextColor(Color.WHITE)
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, 56.0f)
|
||||
tv.setPaddingRelative(114.PX, 61.PX, 114.PX, 61.PX)
|
||||
tv.text = text
|
||||
pop.contentView = tv
|
||||
val reminder = object : PopupWindowReminder(pop) {
|
||||
override fun show() {
|
||||
pop.showAtLocation(activity.window.decorView, Gravity.CENTER, 0, 0)
|
||||
lifecycleOwner().lifecycleScope.launch {
|
||||
delay(unit.toMillis(duration))
|
||||
hide()
|
||||
}
|
||||
}
|
||||
override fun isOverride(): Boolean = true
|
||||
}
|
||||
Reminder.enqueue(activity.lifeCycleOwner, reminder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user