Java 类com.facebook.internal.NativeAppCallAttachmentStore 实例源码

项目:kognitivo    文件:FacebookContentProvider.java   
@Override
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri, java.lang.String mode)
        throws java.io.FileNotFoundException {

    Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
    if (callIdAndAttachmentName == null) {
        throw new FileNotFoundException();
    }

    try {
        File file = NativeAppCallAttachmentStore.openAttachment(
                callIdAndAttachmentName.first,
                callIdAndAttachmentName.second);

        return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    } catch (FileNotFoundException exception) {
        Log.e(TAG, "Got unexpected exception:" + exception);
        throw exception;
    }
}
项目:kognitivo    文件:ShareInternalUtility.java   
public static String getVideoUrl(final ShareVideoContent videoContent, final UUID appCallId) {
    if (videoContent == null || videoContent.getVideo() == null) {
        return null;
    }

    NativeAppCallAttachmentStore.Attachment attachment =
            NativeAppCallAttachmentStore.createAttachment(
                    appCallId,
                    videoContent.getVideo().getLocalUrl());

    ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>(1);
    attachments.add(attachment);
    NativeAppCallAttachmentStore.addAttachments(attachments);

    return attachment.getAttachmentUrl();
}
项目:kognitivo    文件:ShareInternalUtility.java   
private static NativeAppCallAttachmentStore.Attachment getAttachment(
        UUID callId,
        SharePhoto photo) {
    Bitmap bitmap = photo.getBitmap();
    Uri photoUri = photo.getImageUrl();
    NativeAppCallAttachmentStore.Attachment attachment = null;
    if (bitmap != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                bitmap);
    } else if (photoUri != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                photoUri);
    }

    return attachment;
}
项目:Move-Alarm_ORCA    文件:FacebookContentProvider.java   
@Override
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri, java.lang.String mode)
        throws java.io.FileNotFoundException {

    Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
    if (callIdAndAttachmentName == null) {
        throw new FileNotFoundException();
    }

    try {
        File file = NativeAppCallAttachmentStore.openAttachment(
                callIdAndAttachmentName.first,
                callIdAndAttachmentName.second);

        return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    } catch (FileNotFoundException exception) {
        Log.e(TAG, "Got unexpected exception:" + exception);
        throw exception;
    }
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
private static NativeAppCallAttachmentStore.Attachment getAttachment(
        UUID callId,
        SharePhoto photo) {
    Bitmap bitmap = photo.getBitmap();
    Uri photoUri = photo.getImageUrl();
    NativeAppCallAttachmentStore.Attachment attachment = null;
    if (bitmap != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                bitmap);
    } else if (photoUri != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                photoUri);
    }

    return attachment;
}
项目:SocioBlood    文件:FacebookContentProvider.java   
@Override
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri, java.lang.String mode)
        throws java.io.FileNotFoundException {

    Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
    if (callIdAndAttachmentName == null) {
        throw new FileNotFoundException();
    }

    try {
        File file = NativeAppCallAttachmentStore.openAttachment(
                callIdAndAttachmentName.first,
                callIdAndAttachmentName.second);

        return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    } catch (FileNotFoundException exception) {
        Log.e(TAG, "Got unexpected exception:" + exception);
        throw exception;
    }
}
项目:SocioBlood    文件:ShareInternalUtility.java   
private static NativeAppCallAttachmentStore.Attachment getAttachment(
        UUID callId,
        SharePhoto photo) {
    Bitmap bitmap = photo.getBitmap();
    Uri photoUri = photo.getImageUrl();
    NativeAppCallAttachmentStore.Attachment attachment = null;
    if (bitmap != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                bitmap);
    } else if (photoUri != null) {
        attachment = NativeAppCallAttachmentStore.createAttachment(
                callId,
                photoUri);
    }

    return attachment;
}
项目:kognitivo    文件:ShareInternalUtility.java   
public static boolean handleActivityResult(
        int requestCode,
        int resultCode,
        Intent data,
        ResultProcessor resultProcessor) {
    AppCall appCall = getAppCallFromActivityResult(requestCode, resultCode, data);
    if (appCall == null) {
        return false;
    }

    NativeAppCallAttachmentStore.cleanupAttachmentsForCall(appCall.getCallId());
    if (resultProcessor == null) {
        return true;
    }

    FacebookException exception = NativeProtocol.getExceptionFromErrorData(
            NativeProtocol.getErrorDataFromResultIntent(data));
    if (exception != null) {
        if (exception instanceof FacebookOperationCanceledException) {
            resultProcessor.onCancel(appCall);
        } else {
            resultProcessor.onError(appCall, exception);
        }
    } else {
        // If here, we did not find an error in the result.
        Bundle results = NativeProtocol.getSuccessResultsFromIntent(data);
        resultProcessor.onSuccess(appCall, results);
    }

    return true;
}
项目:letv    文件:FacebookContentProvider.java   
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
    Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
    if (callIdAndAttachmentName == null) {
        throw new FileNotFoundException();
    }
    try {
        return ParcelFileDescriptor.open(NativeAppCallAttachmentStore.openAttachment((UUID) callIdAndAttachmentName.first, (String) callIdAndAttachmentName.second), 268435456);
    } catch (FileNotFoundException exception) {
        Log.e(TAG, "Got unexpected exception:" + exception);
        throw exception;
    }
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static boolean handleActivityResult(
        int requestCode,
        int resultCode,
        Intent data,
        ResultProcessor resultProcessor) {
    AppCall appCall = getAppCallFromActivityResult(requestCode, resultCode, data);
    if (appCall == null) {
        return false;
    }

    NativeAppCallAttachmentStore.cleanupAttachmentsForCall(appCall.getCallId());
    if (resultProcessor == null) {
        return true;
    }

    FacebookException exception = NativeProtocol.getExceptionFromErrorData(
            NativeProtocol.getErrorDataFromResultIntent(data));
    if (exception != null) {
        if (exception instanceof FacebookOperationCanceledException) {
            resultProcessor.onCancel(appCall);
        } else {
            resultProcessor.onError(appCall, exception);
        }
    } else {
        // If here, we did not find an error in the result.
        Bundle results = NativeProtocol.getSuccessResultsFromIntent(data);
        resultProcessor.onSuccess(appCall, results);
    }

    return true;
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static JSONObject toJSONObjectForCall(
        final UUID callId,
        final ShareOpenGraphAction action)
        throws JSONException {

    final ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>();
    JSONObject actionJSON = OpenGraphJSONUtility.toJSONObject(
            action,
            new OpenGraphJSONUtility.PhotoJSONProcessor() {
                @Override
                public JSONObject toJSONObject(SharePhoto photo) {
                    NativeAppCallAttachmentStore.Attachment attachment = getAttachment(
                            callId,
                            photo);

                    if (attachment == null) {
                        return null;
                    }

                    attachments.add(attachment);

                    JSONObject photoJSONObject = new JSONObject();
                    try {
                        photoJSONObject.put(
                                NativeProtocol.IMAGE_URL_KEY, attachment.getAttachmentUrl());
                        if (photo.getUserGenerated()) {
                            photoJSONObject.put(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
                        }
                    } catch (JSONException e) {
                        throw new FacebookException("Unable to attach images", e);
                    }
                    return photoJSONObject;
                }
            });

    NativeAppCallAttachmentStore.addAttachments(attachments);

    return actionJSON;
}
项目:SocioBlood    文件:ShareInternalUtility.java   
public static boolean handleActivityResult(
        int requestCode,
        int resultCode,
        Intent data,
        ResultProcessor resultProcessor) {
    AppCall appCall = getAppCallFromActivityResult(requestCode, resultCode, data);
    if (appCall == null) {
        return false;
    }

    NativeAppCallAttachmentStore.cleanupAttachmentsForCall(appCall.getCallId());
    if (resultProcessor == null) {
        return true;
    }

    FacebookException exception = NativeProtocol.getExceptionFromErrorData(
            NativeProtocol.getErrorDataFromResultIntent(data));
    if (exception != null) {
        if (exception instanceof FacebookOperationCanceledException) {
            resultProcessor.onCancel(appCall);
        } else {
            resultProcessor.onError(appCall, exception);
        }
    } else {
        // If here, we did not find an error in the result.
        Bundle results = NativeProtocol.getSuccessResultsFromIntent(data);
        resultProcessor.onSuccess(appCall, results);
    }

    return true;
}
项目:SocioBlood    文件:ShareInternalUtility.java   
public static JSONObject toJSONObjectForCall(
        final UUID callId,
        final ShareOpenGraphAction action)
        throws JSONException {

    final ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>();
    JSONObject actionJSON = OpenGraphJSONUtility.toJSONObject(
            action,
            new OpenGraphJSONUtility.PhotoJSONProcessor() {
                @Override
                public JSONObject toJSONObject(SharePhoto photo) {
                    NativeAppCallAttachmentStore.Attachment attachment = getAttachment(
                            callId,
                            photo);

                    if (attachment == null) {
                        return null;
                    }

                    attachments.add(attachment);

                    JSONObject photoJSONObject = new JSONObject();
                    try {
                        photoJSONObject.put(
                                NativeProtocol.IMAGE_URL_KEY, attachment.getAttachmentUrl());
                        if (photo.getUserGenerated()) {
                            photoJSONObject.put(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
                        }
                    } catch (JSONException e) {
                        throw new FacebookException("Unable to attach images", e);
                    }
                    return photoJSONObject;
                }
            });

    NativeAppCallAttachmentStore.addAttachments(attachments);

    return actionJSON;
}
项目:kognitivo    文件:ShareInternalUtility.java   
public static JSONObject toJSONObjectForCall(
        final UUID callId,
        final ShareOpenGraphContent content)
        throws JSONException {
    final ShareOpenGraphAction action = content.getAction();
    final ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>();
    JSONObject actionJSON = OpenGraphJSONUtility.toJSONObject(
            action,
            new OpenGraphJSONUtility.PhotoJSONProcessor() {
                @Override
                public JSONObject toJSONObject(SharePhoto photo) {
                    NativeAppCallAttachmentStore.Attachment attachment = getAttachment(
                            callId,
                            photo);

                    if (attachment == null) {
                        return null;
                    }

                    attachments.add(attachment);

                    JSONObject photoJSONObject = new JSONObject();
                    try {
                        photoJSONObject.put(
                                NativeProtocol.IMAGE_URL_KEY, attachment.getAttachmentUrl());
                        if (photo.getUserGenerated()) {
                            photoJSONObject.put(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
                        }
                    } catch (JSONException e) {
                        throw new FacebookException("Unable to attach images", e);
                    }
                    return photoJSONObject;
                }
            });

    NativeAppCallAttachmentStore.addAttachments(attachments);
    // People and place tags must be moved from the share content to the open graph action
    if (content.getPlaceId() != null) {
        String placeTag = actionJSON.optString("place");

        // Only if the place tag is already empty or null replace with the id from the
        // share content
        if (Utility.isNullOrEmpty(placeTag)) {
            actionJSON.put("place", content.getPlaceId());
        }
    }

    if (content.getPeopleIds() != null) {
        JSONArray peopleTags = actionJSON.optJSONArray("tags");
        Set<String> peopleIdSet = peopleTags == null
                ? new HashSet<String>()
                : Utility.jsonArrayToSet(peopleTags);

        for (String peopleId : content.getPeopleIds()) {
            peopleIdSet.add(peopleId);
        }
        actionJSON.put("tags", new ArrayList<>(peopleIdSet));
    }

    return actionJSON;
}