Skip to content

Commit

Permalink
Merge pull request #4451 from bijupmb/TIMOB-14505-NullPointerExceptio…
Browse files Browse the repository at this point in the history
…nAlertDialogReusing

TIMOB-14505 set activity for avoid null exception
  • Loading branch information
hieupham007 committed Jul 19, 2013
2 parents a725858 + d99482e commit 40fdfbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ public void show(KrollDict options)
{
AlertDialog dialog = dialogWrapper.getDialog();
if (dialog == null) {
if (dialogWrapper.getActivity() == null) {
TiBaseActivity dialogActivity = (TiBaseActivity) getCurrentActivity();
dialogWrapper.setActivity(new WeakReference<TiBaseActivity>(dialogActivity));
}
processProperties(proxy.getProperties());
getBuilder().setOnCancelListener(new OnCancelListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ public DialogWrapper(AlertDialog d, boolean persistent, WeakReference<TiBaseActi

public TiBaseActivity getActivity()
{
return dialogActivity.get();
if (dialogActivity == null) {
return null;
} else {
return dialogActivity.get();
}
}


public void setActivity(WeakReference<TiBaseActivity> da)
{
dialogActivity = da;
}

public AlertDialog getDialog() {
return dialog;
}
Expand Down

0 comments on commit 40fdfbb

Please sign in to comment.