use of com.orgzly.android.Shelf in project orgzly-android by orgzly.
the class MainActivity method openNote.
private void openNote(long noteId) {
finishActionMode();
// TODO: Avoid using Shelf from activity directly
Shelf shelf = new Shelf(this);
Note note = shelf.getNote(noteId);
if (note != null) {
long bookId = note.getPosition().getBookId();
Intent intent = new Intent(AppIntent.ACTION_OPEN_NOTE);
intent.putExtra(AppIntent.EXTRA_NOTE_ID, noteId);
intent.putExtra(AppIntent.EXTRA_BOOK_ID, bookId);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
}
}
use of com.orgzly.android.Shelf in project orgzly-android by orgzly.
the class MainActivity method onResume.
@Override
protected void onResume() {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG);
super.onResume();
if (clearFragmentBackstack) {
DisplayManager.clear(getSupportFragmentManager());
clearFragmentBackstack = false;
}
performIntros();
Shelf shelf = new Shelf(this);
shelf.syncOnResume();
}
use of com.orgzly.android.Shelf in project orgzly-android by orgzly.
the class ShareActivity method getBooksList.
/**
* Collects list of books from database.
* If there are no books available, create one.
*/
private List<Book> getBooksList() {
Shelf shelf = new Shelf(this);
List<Book> books = shelf.getBooks();
if (books.size() == 0) {
try {
Book book = shelf.createBook(AppPreferences.shareNotebook(getApplicationContext()));
books.add(book);
} catch (IOException e) {
// TODO: Test and handle better.
e.printStackTrace();
finish();
}
}
return books;
}
use of com.orgzly.android.Shelf in project orgzly-android by orgzly.
the class ShareActivity method onResume.
@Override
protected void onResume() {
super.onResume();
Shelf shelf = new Shelf(this);
shelf.syncOnResume();
if (mError != null) {
showSimpleSnackbarLong(mError);
mError = null;
}
}
use of com.orgzly.android.Shelf in project orgzly-android by orgzly.
the class LocalDbRepoTest method testGetBooksFromAllRepos.
@Test
public void testGetBooksFromAllRepos() throws IOException {
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupRook("mock://repo-a", "mock://repo-a/mock-book.org", "book content\n\n* First note\n** Second note", "rev1", 1234567890000L);
List<VersionedRook> books = new Shelf(context).getBooksFromAllRepos(null);
assertEquals(1, books.size());
VersionedRook vrook = books.get(0);
assertEquals("mock-book", BookName.getInstance(context, vrook).getName());
assertEquals("mock://repo-a", vrook.getRepoUri().toString());
assertEquals("mock://repo-a/mock-book.org", vrook.getUri().toString());
assertEquals("rev1", vrook.getRevision());
assertEquals(1234567890000L, vrook.getMtime());
}
Aggregations