Skip to content

Commit c84b24f

Browse files
committed
fix:修复吸附时中心点判断异常
1 parent 27f2e8b commit c84b24f

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

floatingx/src/main/java/com/petterp/floatingx/assist/helper/FxAppHelper.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FxAppHelper(
2828
/** 是否允许插入全部Activity */
2929
@JvmSynthetic
3030
internal val isAllInstall: Boolean,
31-
31+
/** 显示的scope */
3232
@JvmSynthetic
3333
internal var scope: FxScopeType,
3434

@@ -60,19 +60,19 @@ class FxAppHelper(
6060
@JvmSynthetic
6161
internal fun isCanInstall(cls: Class<*>): Boolean {
6262
return (isAllInstall && !blackFilterList.contains(cls)) ||
63-
(!isAllInstall && whiteInsertList.contains(cls))
63+
(!isAllInstall && whiteInsertList.contains(cls))
6464
}
6565

6666
class Builder : FxBasisHelper.Builder<Builder, FxAppHelper>() {
67-
private var whiteInsertList: MutableList<Class<*>> = mutableListOf()
68-
private var blackFilterList: MutableList<Class<*>> = mutableListOf()
69-
private var fxLifecycleExpand: IFxProxyTagActivityLifecycle? = null
70-
private var isEnableAllInstall: Boolean = true
71-
private var context: Application? = null
72-
private var tag = FX_DEFAULT_TAG
7367
private var enableFx = false
68+
private var tag = FX_DEFAULT_TAG
69+
private var context: Application? = null
70+
private var isEnableAllInstall: Boolean = true
7471
private var scopeEnum: FxScopeType = FxScopeType.APP
72+
private var fxLifecycleExpand: IFxProxyTagActivityLifecycle? = null
7573
private var askPermissionInterceptor: IFxPermissionInterceptor? = null
74+
private var whiteInsertList: MutableList<Class<*>> = mutableListOf()
75+
private var blackFilterList: MutableList<Class<*>> = mutableListOf()
7676

7777
/** 用于启用全局浮窗标志,与control.show()同理
7878
*

floatingx/src/main/java/com/petterp/floatingx/view/FxSystemContainerView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class FxSystemContainerView @JvmOverloads constructor(
9797
height = helper.layoutParams?.height ?: WindowManager.LayoutParams.WRAP_CONTENT
9898
format = PixelFormat.RGBA_8888
9999
gravity = Gravity.TOP or Gravity.START
100-
flags =
101-
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
100+
flags = (WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
101+
or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
102102
type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
103103
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
104104
} else {

floatingx/src/main/java/com/petterp/floatingx/view/helper/FxViewLocationHelper.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.petterp.floatingx.assist.FxGravity
88
import com.petterp.floatingx.util.coerceInFx
99
import com.petterp.floatingx.util.shr
1010
import com.petterp.floatingx.view.FxBasicContainerView
11+
import kotlin.math.abs
1112

1213
/**
1314
* 浮窗坐标的配置助手,用于处理坐标相关的处理
@@ -187,12 +188,14 @@ class FxViewLocationHelper : FxViewBasicHelper(), View.OnLayoutChangeListener {
187188

188189
private fun isNearestLeft(x: Float): Boolean {
189190
val middle = parentW / 2
190-
return x < middle
191+
val viewMiddlePoint = x + viewW / 2
192+
return viewMiddlePoint < middle
191193
}
192194

193195
private fun isNearestTop(y: Float): Boolean {
194196
val middle = parentH / 2
195-
return y < middle
197+
val viewMiddlePoint = y + viewH / 2
198+
return viewMiddlePoint < middle
196199
}
197200

198201
private fun getHistoryXY(): Pair<Float, Float> {

0 commit comments

Comments
 (0)