use of com.orgzly.android.sync.BookNamesake in project orgzly-android by orgzly.
the class Shelf method groupAllNotebooksByName.
/**
* Compares every local book with every remote one and calculates the status for each link.
*
* @return number of links (unique book names)
* @throws IOException
*/
public Map<String, BookNamesake> groupAllNotebooksByName() throws IOException {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, "Collecting all local and remote books ...");
Map<String, Repo> repos = ReposClient.getAll(mContext);
List<Book> localBooks = getBooks();
List<VersionedRook> versionedRooks = getBooksFromAllRepos(repos);
/* Group local and remote books by name. */
Map<String, BookNamesake> namesakes = BookNamesake.getAll(mContext, localBooks, versionedRooks);
/* If there is no local book, create empty "dummy" one. */
for (BookNamesake namesake : namesakes.values()) {
if (namesake.getBook() == null) {
Book book = createDummyBook(namesake.getName());
namesake.setBook(book);
}
namesake.updateStatus(repos.size());
}
return namesakes;
}
Aggregations