diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 3a182552..086005f8 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -2,7 +2,9 @@ package one.nem.lacerta.data.impl; import java.text.DateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; @@ -28,23 +30,26 @@ public class LacertaLibraryImpl implements LacertaLibrary { } @Override - public ArrayList getRecentDocument(int limit) { - List documentEntities = database.documentDao().getRecentDocument(limit); + public CompletableFuture> getRecentDocument(int limit) { + return CompletableFuture.supplyAsync(() -> { + List documentEntities = database.documentDao().getRecentDocument(limit); - ArrayList listItems = new ArrayList<>(); - for (DocumentEntity documentEntity : documentEntities) { - ListItem listItem = new ListItem(); - listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); - listItem.setTitle(documentEntity.title); - listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); - listItem.setItemId(documentEntity.id); - listItems.add(listItem); - } - return listItems; + ArrayList listItems = new ArrayList<>(); + for (DocumentEntity documentEntity : documentEntities) { + ListItem listItem = new ListItem(); + listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); + listItem.setTitle(documentEntity.title); + listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); + listItem.setItemId(documentEntity.id); + listItems.add(listItem); + } + + return listItems; + }); } @Override - public ArrayList getRecentDocument(int limit, int offset) { + public CompletableFuture> getRecentDocument(int limit, int offset) { return null; // TODO-rca: Implement }