mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
getRecentDocumentを非同期に
This commit is contained in:
parent
4ab13508c4
commit
4e5aab276a
|
@ -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<ListItem> getRecentDocument(int limit) {
|
||||
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
|
||||
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
|
||||
|
||||
ArrayList<ListItem> 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<ListItem> 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<ListItem> getRecentDocument(int limit, int offset) {
|
||||
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset) {
|
||||
return null; // TODO-rca: Implement
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user