From 089887e72a6d8aef81809e512c49cfb3e9ea1328 Mon Sep 17 00:00:00 2001 From: lfree Date: Thu, 3 May 2018 16:31:59 +0700 Subject: [PATCH] add a null check which may cause crashing --- .../com/vansuita/pickimage/dialog/PickImageBaseDialog.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/vansuita/pickimage/dialog/PickImageBaseDialog.java b/library/src/main/java/com/vansuita/pickimage/dialog/PickImageBaseDialog.java index 67406fb..2826d74 100644 --- a/library/src/main/java/com/vansuita/pickimage/dialog/PickImageBaseDialog.java +++ b/library/src/main/java/com/vansuita/pickimage/dialog/PickImageBaseDialog.java @@ -97,6 +97,9 @@ private void onAttaching() { if (onPickResult == null && getActivity() instanceof IPickResult) onPickResult = (IPickResult) getActivity(); + + if (onPickCancel == null && getActivity() instanceof IPickCancel) + onPickCancel = (IPickCancel) getActivity(); } @@ -160,7 +163,8 @@ private void onBindViewListeners() { @Override public void onClick(View view) { if (view.getId() == R.id.cancel) { - onPickCancel.onCancelClick(); + if (onPickCancel != null) + onPickCancel.onCancelClick(); dismiss(); } else { if (view.getId() == R.id.camera) {