Search in sources :

Example 1 with BaseImageWidget

use of org.odk.collect.android.widgets.BaseImageWidget in project collect by opendatakit.

the class MediaLoadingTask method doInBackground.

@Override
protected File doInBackground(Uri... uris) {
    FormController formController = Collect.getInstance().getFormController();
    if (formController != null) {
        File instanceFile = formController.getInstanceFile();
        if (instanceFile != null) {
            String extension = ContentUriHelper.getFileExtensionFromUri(uris[0]);
            File newFile = FileUtils.createDestinationMediaFile(instanceFile.getParent(), extension);
            FileUtils.saveAnswerFileFromUri(uris[0], newFile, Collect.getInstance());
            QuestionWidget questionWidget = formEntryActivity.get().getWidgetWaitingForBinaryData();
            // apply image conversion if the widget is an image widget
            if (questionWidget instanceof BaseImageWidget) {
                String imageSizeMode = settingsProvider.getUnprotectedSettings().getString(KEY_IMAGE_SIZE);
                ImageConverter.execute(newFile.getPath(), questionWidget, formEntryActivity.get(), imageSizeMode);
            }
            return newFile;
        }
    }
    return null;
}
Also used : FormController(org.odk.collect.android.javarosawrapper.FormController) QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) File(java.io.File) BaseImageWidget(org.odk.collect.android.widgets.BaseImageWidget)

Aggregations

File (java.io.File)1 FormController (org.odk.collect.android.javarosawrapper.FormController)1 BaseImageWidget (org.odk.collect.android.widgets.BaseImageWidget)1 QuestionWidget (org.odk.collect.android.widgets.QuestionWidget)1