Java 类com.facebook.widget.FacebookDialog.PendingCall 实例源码

项目:RetroFacebook    文件:Facebook.java   
private Observable<Bundle> trackPendingDialogCall(FacebookDialog shareDialog) {
    Log.d("RetroFacebook", "trackPendingDialogCall");
    //Subject<Bundle, Bundle> sub = BehaviorSubject.create();
    //dialogSubject = BehaviorSubject.create();
    PendingCall pendingCall = shareDialog.present();
    //dialogSubs.put(pendingCall.getCallId(), sub);
    uiLifecycleHelper.trackPendingDialogCall(pendingCall);

    //return sub.asObservable();
    return dialogSubject.asObservable().take(1);
}
项目:QuizUpWinner    文件:UiLifecycleHelper.java   
public void onCreate(Bundle paramBundle)
{
  Session localSession1 = Session.getActiveSession();
  Session localSession2 = localSession1;
  if (localSession1 == null)
  {
    if (paramBundle != null)
      localSession2 = Session.restoreSession(this.activity, null, this.callback, paramBundle);
    if (localSession2 == null)
      localSession2 = new Session(this.activity);
    Session.setActiveSession(localSession2);
  }
  if (paramBundle != null)
    this.pendingFacebookDialogCall = ((FacebookDialog.PendingCall)paramBundle.getParcelable("com.facebook.UiLifecycleHelper.pendingFacebookDialogCallKey"));
}
项目:RetroFacebook    文件:Facebook.java   
public Facebook initialize(Activity activity) {
    this.activity = activity;
    sessionSubject = PublishSubject.create();
    sessionStatusCallback = new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (exception != null) {
                sessionSubject.onError(exception);
            } else {
                sessionSubject.onNext(session);
            }
        }
    };

    dialogSubject = PublishSubject.create();
    dialogCallback = new FacebookDialog.Callback() {
        @Override
        public void onError(PendingCall pendingCall, Exception error, Bundle data) {
            Log.d("RetroFacebook", "dialogCallback.onError: " + pendingCall);
            Log.d("RetroFacebook", "dialogCallback.onError: " + error);
            error.printStackTrace();
            //Subject<Bundle, Bundle> sub = dialogSubs.get(pendingCall.getCallId());
            Subject<Bundle, Bundle> sub = dialogSubject;
            if (sub != null) {
                sub.onError(error);
                dialogSubs.remove(pendingCall.getCallId());
            }
        }

        @Override
        public void onComplete(PendingCall pendingCall, Bundle data) {
            Log.d("RetroFacebook", "dialogCallback.onComplete: " + pendingCall);
            //Subject<Bundle, Bundle> sub = dialogSubs.get(pendingCall.getCallId());
            Subject<Bundle, Bundle> sub = dialogSubject;
            if (sub != null) {
                sub.onNext(data);
                //sub.onCompleted();
                dialogSubs.remove(pendingCall.getCallId());
            }
            /*
            boolean didComplete = FacebookDialog.getNativeDialogDidComplete(data);
            String postId = FacebookDialog.getNativeDialogPostId(data);
            String completeGesture = FacebookDialog.getNativeDialogCompletionGesture(data);
            if (completeGesture != null) {
                if (completeGesture.equals("post")) {
                    mOnPublishListener.onComplete(postId != null ? postId : "no postId return");
                } else {
                    mOnPublishListener.onFail("Canceled by user");
                }
            } else if (didComplete) {
                mOnPublishListener.onComplete(postId != null ? postId : "published successfully. (post id is not availaible if you are not logged in)");
            } else {
                mOnPublishListener.onFail("Canceled by user");
            }
            */
        }
    };

    uiLifecycleHelper = new UiLifecycleHelper(activity, sessionStatusCallback);

    return this;
}
项目:QuizUpWinner    文件:UiLifecycleHelper.java   
public void trackPendingDialogCall(FacebookDialog.PendingCall paramPendingCall)
{
  if (this.pendingFacebookDialogCall != null)
    cancelPendingAppCall(null);
  this.pendingFacebookDialogCall = paramPendingCall;
}