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

The following examples show how to use com.facebook.internal.NativeProtocol#isErrorResult() . 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;
}
 
Example 9
Source File: FacebookBroadcastReceiver.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
    if (appCallId != null && action != null) {
        Bundle extras = intent.getExtras();

        if (NativeProtocol.isErrorResult(intent)) {
            onFailedAppCall(appCallId, action, extras);
        } else {
            onSuccessfulAppCall(appCallId, action, extras);
        }
    }
}
 
Example 10
Source File: FacebookBroadcastReceiver.java    From android-skeleton-project with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
    if (appCallId != null && action != null) {
        Bundle extras = intent.getExtras();

        if (NativeProtocol.isErrorResult(intent)) {
            onFailedAppCall(appCallId, action, extras);
        } else {
            onSuccessfulAppCall(appCallId, action, extras);
        }
    }
}
 
Example 11
Source File: FacebookBroadcastReceiver.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
    if (appCallId != null && action != null) {
        Bundle extras = intent.getExtras();

        if (NativeProtocol.isErrorResult(intent)) {
            onFailedAppCall(appCallId, action, extras);
        } else {
            onSuccessfulAppCall(appCallId, action, extras);
        }
    }
}
 
Example 12
Source File: FacebookBroadcastReceiver.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
    if (appCallId != null && action != null) {
        Bundle extras = intent.getExtras();

        if (NativeProtocol.isErrorResult(intent)) {
            onFailedAppCall(appCallId, action, extras);
        } else {
            onSuccessfulAppCall(appCallId, action, extras);
        }
    }
}
 
Example 13
Source File: FacebookBroadcastReceiver.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String appCallId = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_CALL_ID);
    String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION);
    if (appCallId != null && action != null) {
        Bundle extras = intent.getExtras();

        if (NativeProtocol.isErrorResult(intent)) {
            onFailedAppCall(appCallId, action, extras);
        } else {
            onSuccessfulAppCall(appCallId, action, extras);
        }
    }
}