Search in sources :

Example 1 with Shelf

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);
    }
}
Also used : Note(com.orgzly.android.Note) Shelf(com.orgzly.android.Shelf) Intent(android.content.Intent) AppIntent(com.orgzly.android.AppIntent)

Example 2 with Shelf

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();
}
Also used : Shelf(com.orgzly.android.Shelf)

Example 3 with Shelf

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;
}
Also used : Book(com.orgzly.android.Book) Shelf(com.orgzly.android.Shelf) IOException(java.io.IOException)

Example 4 with Shelf

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;
    }
}
Also used : Shelf(com.orgzly.android.Shelf)

Example 5 with Shelf

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());
}
Also used : Shelf(com.orgzly.android.Shelf) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Aggregations

Shelf (com.orgzly.android.Shelf)16 Book (com.orgzly.android.Book)4 Intent (android.content.Intent)3 AppIntent (com.orgzly.android.AppIntent)3 Note (com.orgzly.android.Note)3 IOException (java.io.IOException)3 Uri (android.net.Uri)2 Fragment (android.support.v4.app.Fragment)2 Toolbar (android.support.v7.widget.Toolbar)2 Query (com.orgzly.android.query.Query)2 File (java.io.File)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1 TypedArray (android.content.res.TypedArray)1