Skip to content

Commit

Permalink
Creating dismiss callback
Browse files Browse the repository at this point in the history
  • Loading branch information
secondsun committed Oct 30, 2014
1 parent d932d18 commit b0b340f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.jboss.aerogear.android.impl.authz.oauth2;

import android.app.DialogFragment;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -48,7 +49,7 @@ public class OAuthWebViewDialog extends DialogFragment {
private WebView webView;
private ProgressBar progressBar;
private String authorizeUrl;
private OAuthViewClient client = new OAuthViewClient() {
final private OAuthViewClient client = new OAuthViewClient() {

@Override
public void onPageFinished(WebView view, String url) {
Expand Down Expand Up @@ -160,6 +161,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return v;
}

@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (client.receiver != null) {
client.receiver.receiveOAuthError(OAuthReceiver.DISMISS_ERROR);
}
}

public void setReceiver(OAuthReceiver receiver) {
client.receiver = receiver;
}
Expand All @@ -170,6 +179,8 @@ public void removeReceive() {

public interface OAuthReceiver {

public static final String DISMISS_ERROR = "dialog_dismissed";

void receiveOAuthCode(String code);

public void receiveOAuthError(String error);
Expand Down

0 comments on commit b0b340f

Please sign in to comment.