Skip to content

Commit 1b57bf3

Browse files
committed
修复在设置拖拽规则为空时没有生效的问题
1 parent e63c844 commit 1b57bf3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

library/src/main/java/com/hjq/window/EasyWindow.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -906,17 +906,29 @@ public X setWindowParams(@NonNull WindowManager.LayoutParams params) {
906906
* {@link SpringBackWindowDraggableRule }:在 MovingWindowDraggableRule 的基础上,加上了在手指释放时触发回弹到边缘的动画
907907
*/
908908
public X setWindowDraggableRule(@Nullable AbstractWindowDraggableRule windowDraggableRule) {
909-
mWindowDraggableRule = windowDraggableRule;
910-
if (windowDraggableRule != null) {
911-
// 如果当前是否设置了不可触摸,如果是就擦除掉这个标记
912-
removeWindowFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
913-
// 如果当前是否设置了可移动窗口到屏幕之外,如果是就擦除这个标记
914-
removeWindowFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
915-
916-
if (isShowing()) {
917-
update();
918-
windowDraggableRule.start(this);
909+
if (windowDraggableRule == null) {
910+
if (mWindowDraggableRule != null) {
911+
mWindowDraggableRule.recycle();
912+
mWindowDraggableRule = null;
913+
}
914+
915+
if (mScreenOrientationMonitor != null) {
916+
mScreenOrientationMonitor.unregisterCallback(mContext);
917+
mScreenOrientationMonitor = null;
919918
}
919+
return (X) this;
920+
}
921+
922+
mWindowDraggableRule = windowDraggableRule;
923+
924+
// 如果当前是否设置了不可触摸,如果是就擦除掉这个标记
925+
removeWindowFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
926+
// 如果当前是否设置了可移动窗口到屏幕之外,如果是就擦除这个标记
927+
removeWindowFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
928+
929+
if (isShowing()) {
930+
update();
931+
windowDraggableRule.start(this);
920932
}
921933

922934
Resources resources = null;

0 commit comments

Comments
 (0)