Search in sources :

Example 1 with FileReader

use of com.googlecode.gwtphonegap.client.file.FileReader in project gwtphonegap by dankurka.

the class CameraBrowserFileInput method getBase64.

private void getBase64(ReaderCallback<FileReader> callback) {
    FileObjectJsImpl file = getFile(input.getElement());
    FileReader reader = createReader();
    reader.setOnLoadEndCallback(callback);
    reader.readAsDataUrl(file);
}
Also used : FileObjectJsImpl(com.googlecode.gwtphonegap.client.file.js.FileObjectJsImpl) FileReader(com.googlecode.gwtphonegap.client.file.FileReader)

Example 2 with FileReader

use of com.googlecode.gwtphonegap.client.file.FileReader in project gwtphonegap by dankurka.

the class CameraBrowserFileInput method getPicture.

@Override
public CameraPopoverHandle getPicture(final PictureOptions options, final PictureCallback callback) {
    if (!input.isAttached()) {
        callback.onFailure("after #cleanUp(), this instance is no longer useful");
        return popoverHandle;
    }
    @SuppressWarnings("unused") final ChangeHandler handler = new ChangeHandler() {

        private final HandlerRegistration reg = input.addChangeHandler(this);

        @Override
        public void onChange(ChangeEvent event) {
            reg.removeHandler();
            if (options.getDestinationType() == PictureOptions.DESTINATION_TYPE_DATA_URL) {
                getBase64(new ReaderCallback<FileReader>() {

                    @Override
                    public void onCallback(FileReader result) {
                        callback.onSuccess(result.getResult());
                    }
                });
            } else {
                callback.onSuccess(getFileUri());
            }
        }
    };
    open(input.getElement());
    return popoverHandle;
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FileReader(com.googlecode.gwtphonegap.client.file.FileReader)

Aggregations

FileReader (com.googlecode.gwtphonegap.client.file.FileReader)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 FileObjectJsImpl (com.googlecode.gwtphonegap.client.file.js.FileObjectJsImpl)1