use of com.orgzly.android.db.entity.Book in project orgzly-android by orgzly.
the class BookChooserActivity method onBookClicked.
@Override
public void onBookClicked(long bookId) {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, bookId, action);
if (action != null && action.equals(Intent.ACTION_CREATE_SHORTCUT)) {
// Get Book by its ID
Book book = dataRepository.getBook(bookId);
if (book == null) {
Toast.makeText(this, R.string.book_does_not_exist_anymore, Toast.LENGTH_SHORT).show();
setResult(RESULT_CANCELED);
finish();
return;
}
String id = "notebook-" + bookId;
String name = book.getName();
String title = BookUtils.getFragmentTitleForBook(book);
Intent launchIntent = createLaunchIntent(book);
IconCompat icon = createIcon();
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(this, id).setShortLabel(name).setLongLabel(title).setIcon(icon).setIntent(launchIntent).build();
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
finish();
}
}
use of com.orgzly.android.db.entity.Book in project orgzly-android by orgzly.
the class LocalDbRepoTest method testStoringBook.
@Test
public void testStoringBook() throws IOException {
SyncRepo repo;
long now = System.currentTimeMillis();
/* Write local book's content to a temporary file. */
Book book = dataRepository.getBook("local-book-1");
File tmpFile = dataRepository.getTempBookFile();
try {
new NotesOrgExporter(dataRepository).exportBook(book, tmpFile);
repo = testUtils.repoInstance(RepoType.MOCK, "mock://repo-a");
repo.storeBook(tmpFile, BookName.fileName(book.getName(), BookFormat.ORG));
} finally {
tmpFile.delete();
}
List<VersionedRook> books = repo.getBooks();
assertEquals(1, books.size());
VersionedRook vrook = books.get(0);
assertEquals("local-book-1", BookName.getInstance(context, vrook).getName());
assertEquals("mock://repo-a", vrook.getRepoUri().toString());
assertTrue(vrook.getMtime() >= now);
}
Aggregations