com.facebook.widget.FacebookDialog Java Examples

The following examples show how to use com.facebook.widget.FacebookDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UiLifecycleHelper.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #2
Source File: UiLifecycleHelper.java    From android-skeleton-project with MIT License 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #3
Source File: UiLifecycleHelper.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #4
Source File: UiLifecycleHelper.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #5
Source File: UiLifecycleHelper.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #6
Source File: UiLifecycleHelper.java    From Klyph with MIT License 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #7
Source File: UiLifecycleHelper.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #8
Source File: UiLifecycleHelper.java    From KlyphMessenger with MIT License 6 votes vote down vote up
private void cancelPendingAppCall(FacebookDialog.Callback facebookDialogCallback) {
    if (facebookDialogCallback != null) {
        Intent pendingIntent = pendingFacebookDialogCall.getRequestIntent();

        Intent cancelIntent = new Intent();
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION,
                pendingIntent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION));
        cancelIntent.putExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION,
                pendingIntent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
        cancelIntent.putExtra(NativeProtocol.STATUS_ERROR_TYPE, NativeProtocol.ERROR_UNKNOWN_ERROR);

        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall,
                pendingFacebookDialogCall.getRequestCode(), cancelIntent, facebookDialogCallback);
    }
    pendingFacebookDialogCall = null;
}
 
Example #9
Source File: UiLifecycleHelper.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #10
Source File: UiLifecycleHelper.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #11
Source File: UiLifecycleHelper.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #12
Source File: UiLifecycleHelper.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #13
Source File: UiLifecycleHelper.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    UUID callId = NativeProtocol.getCallIdFromIntent(data);

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #14
Source File: UiLifecycleHelper.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #15
Source File: UiLifecycleHelper.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #16
Source File: UiLifecycleHelper.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #17
Source File: UiLifecycleHelper.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    UUID callId = NativeProtocol.getCallIdFromIntent(data);

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #18
Source File: UiLifecycleHelper.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #19
Source File: UiLifecycleHelper.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #20
Source File: UiLifecycleHelper.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #21
Source File: UiLifecycleHelper.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #22
Source File: Facebook.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
public Observable<Bundle> share(Photo photo) {
    Log.d("RetroFacebook", "share");
    //if (FacebookDialog.canPresentShareDialog(activity, ShareDialogFeature.PHOTOS)) {
    //}
    FacebookDialog shareDialog = new FacebookDialog.PhotoShareDialogBuilder(activity)
        .addPhotos(Arrays.asList(photo.pictureBitmap()))
        //.setPlace(photo.placeId())
        .build();

    return trackPendingDialogCall(shareDialog);
}
 
Example #23
Source File: UiLifecycleHelper.java    From android-skeleton-project with MIT License 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #24
Source File: UiLifecycleHelper.java    From android-skeleton-project with MIT License 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #25
Source File: UiLifecycleHelper.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #26
Source File: UiLifecycleHelper.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #27
Source File: UiLifecycleHelper.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}
 
Example #28
Source File: UiLifecycleHelper.java    From Klyph with MIT License 5 votes vote down vote up
private boolean handleFacebookDialogActivityResult(int requestCode, int resultCode, Intent data,
        FacebookDialog.Callback facebookDialogCallback) {
    if (pendingFacebookDialogCall == null || pendingFacebookDialogCall.getRequestCode() != requestCode) {
        return false;
    }

    if (data == null) {
        // We understand the request code, but have no Intent. This can happen if the called Activity crashes
        // before it can be started; we treat this as a cancellation because we have no other information.
        cancelPendingAppCall(facebookDialogCallback);
        return true;
    }

    String callIdString = data.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }

    // Was this result for the call we are waiting on?
    if (callId != null && pendingFacebookDialogCall.getCallId().equals(callId)) {
        // Yes, we can handle it normally.
        FacebookDialog.handleActivityResult(activity, pendingFacebookDialogCall, requestCode, data,
                facebookDialogCallback);
    } else {
        // No, send a cancellation error to the pending call and ignore the result, because we
        // don't know what to do with it.
        cancelPendingAppCall(facebookDialogCallback);
    }

    pendingFacebookDialogCall = null;
    return true;
}
 
Example #29
Source File: UiLifecycleHelper.java    From Klyph with MIT License 5 votes vote down vote up
/**
 * Register that we are expecting results from a call to the Facebook application (e.g., from a native
 * dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed
 * and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked
 * at a time; attempting to track another one will cancel the first one.
 * @param appCall an PendingCall object containing the call ID
 */
public void trackPendingDialogCall(FacebookDialog.PendingCall pendingCall) {
    if (pendingFacebookDialogCall != null) {
        // If one is already pending, cancel it; we don't allow multiple pending calls.
        Log.i("Facebook", "Tracking new app call while one is still pending; canceling pending call.");
        cancelPendingAppCall(null);
    }
    pendingFacebookDialogCall = pendingCall;
}
 
Example #30
Source File: UiLifecycleHelper.java    From Klyph with MIT License 5 votes vote down vote up
/**
 * To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
 * call are expected.
 *
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the result data
 * @param dialogCallback the callback for handling FacebookDialog results, can be null
 */
public void onActivityResult(int requestCode, int resultCode, Intent data,
            FacebookDialog.Callback facebookDialogCallback) {
    Session session = Session.getActiveSession();
    if (session != null) {
        session.onActivityResult(activity, requestCode, resultCode, data);
    }

    handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
}