Skip to content

Commit 6a9397f

Browse files
committed
兼容在极端情况下 WindowManager 添加或者移除 View 时可能会出现崩溃的问题
1 parent a3b346a commit 6a9397f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,7 @@ public void show() {
924924
mOnWindowLifecycleCallback.onWindowShow(this);
925925
}
926926

927-
} catch (NullPointerException | IllegalStateException |
928-
IllegalArgumentException | WindowManager.BadTokenException e) {
927+
} catch (Exception e) {
929928
// 如果这个 View 对象被重复添加到 WindowManager 则会抛出异常
930929
// java.lang.IllegalStateException: View has already been added to the window manager.
931930
e.printStackTrace();
@@ -968,7 +967,7 @@ public void cancel() {
968967
mOnWindowLifecycleCallback.onWindowCancel(this);
969968
}
970969

971-
} catch (NullPointerException | IllegalArgumentException | IllegalStateException e) {
970+
} catch (Exception e) {
972971
e.printStackTrace();
973972
} finally {
974973
// 当前没有显示

0 commit comments

Comments
 (0)