Prevent IllegalArgumentException when closing popup

This commit is contained in:
Stypox 2021-01-17 14:04:07 +01:00
parent 098c954ef1
commit d4a33603ab
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 17 additions and 7 deletions

View File

@ -46,6 +46,6 @@ data class PickerSubscriptionItem(
fun updateSelected(containerView: View, isSelected: Boolean) {
this.isSelected = isSelected
PickerSubscriptionItemBinding.bind(containerView).selectedHighlight
.animate(isSelected, 150, AnimationType.LIGHT_SCALE_AND_ALPHA)
.animate(isSelected, 150, AnimationType.LIGHT_SCALE_AND_ALPHA)
}
}

View File

@ -1349,13 +1349,23 @@ public final class Player implements
public void removePopupFromView() {
if (windowManager != null) {
final boolean isCloseOverlayHasParent = closeOverlayBinding != null
&& closeOverlayBinding.closeButton.getParent() != null;
if (popupHasParent()) {
windowManager.removeView(binding.getRoot());
// wrap in try-catch since it could sometimes generate errors randomly
try {
if (popupHasParent()) {
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);
}
}
}