Java Code Examples for com.facebook.internal.NativeProtocol#getErrorFromResult()

The following examples show how to use com.facebook.internal.NativeProtocol#getErrorFromResult() . 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: FacebookDialog.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context the Context that is handling the activity result
 * @param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data the result Intent
 * @param callback a callback to call after parsing the results
 *
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 2
Source File: FacebookDialog.java    From Klyph with MIT License 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context the Context that is handling the activity result
 * @param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data the result Intent
 * @param callback a callback to call after parsing the results
 *
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 3
Source File: FacebookDialog.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context the Context that is handling the activity result
 * @param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data the result Intent
 * @param callback a callback to call after parsing the results
 *
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 4
Source File: FacebookDialog.java    From android-skeleton-project with MIT License 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context     the Context that is handling the activity result
 * @param appCall     an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data        the result Intent
 * @param callback    a callback to call after parsing the results
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 5
Source File: FacebookDialog.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context     the Context that is handling the activity result
 * @param appCall     an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data        the result Intent
 * @param callback    a callback to call after parsing the results
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 6
Source File: FacebookDialog.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context     the Context that is handling the activity result
 * @param appCall     an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data        the result Intent
 * @param callback    a callback to call after parsing the results
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);

            // TODO  - data.getExtras() doesn't work for the bucketed protocol.
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, NativeProtocol.getSuccessResultsFromIntent(data));
        }
    }

    return true;
}
 
Example 7
Source File: FacebookDialog.java    From KlyphMessenger with MIT License 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context the Context that is handling the activity result
 * @param appCall an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data the result Intent
 * @param callback a callback to call after parsing the results
 *
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, data.getExtras());
        }
    }

    return true;
}
 
Example 8
Source File: FacebookDialog.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the results of a dialog activity and calls the appropriate method on the provided Callback.
 *
 * @param context     the Context that is handling the activity result
 * @param appCall     an PendingCall containing the call ID and original Intent used to launch the dialog
 * @param requestCode the request code for the activity result
 * @param data        the result Intent
 * @param callback    a callback to call after parsing the results
 * @return true if the activity result was handled, false if not
 */
public static boolean handleActivityResult(Context context, PendingCall appCall, int requestCode, Intent data,
        Callback callback) {
    if (requestCode != appCall.getRequestCode()) {
        return false;
    }

    if (attachmentStore != null) {
        attachmentStore.cleanupAttachmentsForCall(context, appCall.getCallId());
    }

    if (callback != null) {
        if (NativeProtocol.isErrorResult(data)) {
            Exception error = NativeProtocol.getErrorFromResult(data);

            // TODO  - data.getExtras() doesn't work for the bucketed protocol.
            callback.onError(appCall, error, data.getExtras());
        } else {
            callback.onComplete(appCall, NativeProtocol.getSuccessResultsFromIntent(data));
        }
    }

    return true;
}