junixapp/XPopup

2.9.19版本如果直接在asCustom中new CustomPopup(getContext() 会报错

Closed this issue · 2 comments

yk007 commented

XPopup版本
2.9.19
描述你的问题
最新版本如果直接在asCustom中new CustomPopup(getContext() 会报错,而老版本不会报错
new XPopup.Builder(getContext())
.asCustom(new CustomPopup(getContext()))
.show();
报错: java.lang.IllegalArgumentException: popupInfo is null, if your popup object is reused, do not set isDestroyOnDismiss(true) !

新版本代码实现
public BasePopupView asCustom(BasePopupView popupView) {
popupView.popupInfo = this.popupInfo;
return popupView;
}
老版本代码实现
public BasePopupView asCustom(BasePopupView popupView) {
if (popupView instanceof CenterPopupView) {
popupType(PopupType.Center);
} else if (popupView instanceof BottomPopupView) {
popupType(PopupType.Bottom);
} else if (popupView instanceof AttachPopupView) {
popupType(PopupType.AttachView);
} else if (popupView instanceof ImageViewerPopupView) {
popupType(PopupType.ImageViewer);
} else if (popupView instanceof PositionPopupView) {
popupType(PopupType.Position);
}
popupView.popupInfo = this.popupInfo;
return popupView;
}

大佬这个怎么解决呢?回退老版本吗?

这是个坑,我也遇到,我尝试着不要链式调用,解决了问题
XPopup.Builder builder = new XPopup.Builder(context);
BasePopupView basePopupView = builder.asCustom(new MyBottomPopup(context));
basePopupView.show();