mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-10 01:45:54 +01:00
Merge pull request #5442 from Stypox/fix-close-popup
Prevent IllegalArgumentException when closing popup
This commit is contained in:
commit
23b5cd5b72
@ -1349,13 +1349,23 @@ public final class Player implements
|
|||||||
|
|
||||||
public void removePopupFromView() {
|
public void removePopupFromView() {
|
||||||
if (windowManager != null) {
|
if (windowManager != null) {
|
||||||
final boolean isCloseOverlayHasParent = closeOverlayBinding != null
|
// wrap in try-catch since it could sometimes generate errors randomly
|
||||||
&& closeOverlayBinding.closeButton.getParent() != null;
|
try {
|
||||||
if (popupHasParent()) {
|
if (popupHasParent()) {
|
||||||
windowManager.removeView(binding.getRoot());
|
windowManager.removeView(binding.getRoot());
|
||||||
|
}
|
||||||
|
} catch (final IllegalArgumentException e) {
|
||||||
|
Log.w(TAG, "Failed to remove popup from window manager", e);
|
||||||
}
|
}
|
||||||
if (isCloseOverlayHasParent) {
|
|
||||||
windowManager.removeView(closeOverlayBinding.getRoot());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user