Java Code Examples for com.facebook.internal.Validate#containsNoNullOrEmpty()

The following examples show how to use com.facebook.internal.Validate#containsNoNullOrEmpty() . 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: NativeAppCallAttachmentStore.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 2
Source File: NativeAppCallAttachmentStore.java    From Klyph with MIT License 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 3
Source File: NativeAppCallAttachmentStore.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 4
Source File: NativeAppCallAttachmentStore.java    From android-skeleton-project with MIT License 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 5
Source File: NativeAppCallAttachmentStore.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 6
Source File: NativeAppCallAttachmentStore.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 7
Source File: NativeAppCallAttachmentStore.java    From KlyphMessenger with MIT License 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 8
Source File: NativeAppCallAttachmentStore.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a number of bitmap attachments associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Bitmaps; the attachment names will be part of
 *                         the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentsForCall(Context context, UUID callId, Map<String, Bitmap> imageAttachments) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachments.values(), "imageAttachments");
    Validate.containsNoNullOrEmpty(imageAttachments.keySet(), "imageAttachments");

    addAttachments(context, callId, imageAttachments, new ProcessAttachment<Bitmap>() {
        @Override
        public void processAttachment(Bitmap attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            try {
                attachment.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            } finally {
                Utility.closeQuietly(outputStream);
            }
        }
    });
}
 
Example 9
Source File: NativeAppCallAttachmentStore.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 10
Source File: NativeAppCallAttachmentStore.java    From Klyph with MIT License 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 11
Source File: NativeAppCallAttachmentStore.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 12
Source File: NativeAppCallAttachmentStore.java    From android-skeleton-project with MIT License 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 13
Source File: NativeAppCallAttachmentStore.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 14
Source File: NativeAppCallAttachmentStore.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 15
Source File: NativeAppCallAttachmentStore.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}
 
Example 16
Source File: NativeAppCallAttachmentStore.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a number of bitmap attachment files associated with a native app call. The attachments will be
 * served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
 *
 * @param context the Context the call is being made from
 * @param callId the unique ID of the call
 * @param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
 *                         part of the URI processed by openFile
 * @throws java.io.IOException
 */
public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
    Validate.notNull(context, "context");
    Validate.notNull(callId, "callId");
    Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
    Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");

    addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
        @Override
        public void processAttachment(File attachment, File outputFile) throws IOException {
            FileOutputStream outputStream = new FileOutputStream(outputFile);
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(attachment);

                byte[] buffer = new byte[1024];
                int len;
                while ((len = inputStream.read(buffer)) > 0) {
                    outputStream.write(buffer, 0, len);
                }
            } finally {
                Utility.closeQuietly(outputStream);
                Utility.closeQuietly(inputStream);
            }
        }
    });
}