1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-09-28 15:08:50 +00:00

Merge pull request #5442 from Stypox/fix-close-popup

Prevent IllegalArgumentException when closing popup
This commit is contained in:
XiangRongLin 2021-01-18 09:39:02 +01:00 committed by GitHub
commit 23b5cd5b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1349,14 +1349,24 @@ public final class Player implements
public void removePopupFromView() {
if (windowManager != null) {
final boolean isCloseOverlayHasParent = closeOverlayBinding != null
&& closeOverlayBinding.closeButton.getParent() != null;
// wrap in try-catch since it could sometimes generate errors randomly
try {
if (popupHasParent()) {
windowManager.removeView(binding.getRoot());
}
if (isCloseOverlayHasParent) {
} catch (final IllegalArgumentException e) {
Log.w(TAG, "Failed to remove popup from window manager", e);
}
try {
final boolean closeOverlayHasParent = closeOverlayBinding != null
&& closeOverlayBinding.getRoot().getParent() != null;
if (closeOverlayHasParent) {
windowManager.removeView(closeOverlayBinding.getRoot());
}
} catch (final IllegalArgumentException e) {
Log.w(TAG, "Failed to remove popup overlay from window manager", e);
}
}
}