Search in sources :

Example 1 with FileType

use of com.faltenreich.diaguard.feature.export.job.FileType in project Diaguard by Faltenreich.

the class ExportFragment method export.

private void export() {
    progressComponent.show(getContext());
    progressComponent.setMessage(getString(R.string.export_progress));
    DateTime dateStart = this.dateStart != null ? this.dateStart.withTimeAtStartOfDay() : null;
    DateTime dateEnd = this.dateEnd != null ? this.dateEnd.withTimeAtStartOfDay() : null;
    Category[] categories = categoryListAdapter.getSelectedCategories();
    PdfExportConfig config = new PdfExportConfig(getContext(), this, dateStart, dateEnd, categories, getStyle(), getBinding().headerCheckbox.isChecked(), getBinding().footerCheckbox.isChecked(), getBinding().noteCheckbox.isChecked(), getBinding().tagsCheckbox.isChecked(), getBinding().emptyDaysCheckbox.isChecked(), categoryListAdapter.exportFood(), categoryListAdapter.splitInsulin(), categoryListAdapter.highlightLimits());
    config.persistInSharedPreferences();
    FileType type = getFormat();
    switch(type) {
        case PDF:
            Export.exportPdf(config);
            break;
        case CSV:
            Export.exportCsv(getContext(), this, dateStart, dateEnd, categories);
            break;
    }
}
Also used : PdfExportConfig(com.faltenreich.diaguard.feature.export.job.pdf.meta.PdfExportConfig) Category(com.faltenreich.diaguard.shared.data.database.entity.Category) FileType(com.faltenreich.diaguard.feature.export.job.FileType) DateTime(org.joda.time.DateTime)

Example 2 with FileType

use of com.faltenreich.diaguard.feature.export.job.FileType in project Diaguard by Faltenreich.

the class ExportHistoryViewHolder method onBind.

@Override
protected void onBind(ExportHistoryListItem item) {
    FileType format = FileType.valueOf(item.getFile());
    getBinding().formatIcon.setColorFilter(ContextCompat.getColor(getContext(), format != null ? format.colorRes : R.color.gray));
    getBinding().formatLabel.setText(format != null ? format.extension : null);
    getBinding().createdAtLabel.setText(DateTimeFormat.mediumDateTime().print(item.getCreatedAt()));
    getBinding().container.setOnClickListener(view -> openExport());
    getBinding().moreButton.setOnClickListener(this::openMenu);
}
Also used : FileType(com.faltenreich.diaguard.feature.export.job.FileType)

Aggregations

FileType (com.faltenreich.diaguard.feature.export.job.FileType)2 PdfExportConfig (com.faltenreich.diaguard.feature.export.job.pdf.meta.PdfExportConfig)1 Category (com.faltenreich.diaguard.shared.data.database.entity.Category)1 DateTime (org.joda.time.DateTime)1