Search in sources :

Example 6 with BookNamesake

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;
}
Also used : VersionedRook(com.orgzly.android.repos.VersionedRook) Repo(com.orgzly.android.repos.Repo) BookNamesake(com.orgzly.android.sync.BookNamesake)

Aggregations

BookNamesake (com.orgzly.android.sync.BookNamesake)6 OrgzlyTest (com.orgzly.android.OrgzlyTest)4 Test (org.junit.Test)4 Book (com.orgzly.android.Book)3 Repo (com.orgzly.android.repos.Repo)1 VersionedRook (com.orgzly.android.repos.VersionedRook)1 IOException (java.io.IOException)1