Search in sources :

Example 6 with Shelf

use of com.orgzly.android.Shelf in project orgzly-android by orgzly.

the class NoteFragment method onAttach.

@Override
public void onAttach(Context context) {
    if (BuildConfig.LOG_DEBUG)
        LogUtils.d(TAG, getActivity());
    super.onAttach(context);
    /* This makes sure that the container activity has implemented
         * the callback interface. If not, it throws an exception
         */
    try {
        mListener = (NoteFragmentListener) getActivity();
    } catch (ClassCastException e) {
        throw new ClassCastException(getActivity().toString() + " must implement " + NoteFragmentListener.class);
    }
    mShelf = new Shelf(getActivity().getApplicationContext());
    parseArguments();
    mUserTimeFormatter = new UserTimeFormatter(getActivity().getApplicationContext());
}
Also used : UserTimeFormatter(com.orgzly.android.util.UserTimeFormatter) Shelf(com.orgzly.android.Shelf)

Example 7 with Shelf

use of com.orgzly.android.Shelf in project orgzly-android by orgzly.

the class ListWidgetProvider method setNoteDone.

@SuppressLint("StaticFieldLeak")
private void setNoteDone(Context context, Intent intent) {
    final Shelf shelf = new Shelf(context);
    final long noteId = intent.getLongExtra(AppIntent.EXTRA_NOTE_ID, 0L);
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            shelf.setStateToFirstDone(noteId);
            return null;
        }
    }.execute();
}
Also used : Shelf(com.orgzly.android.Shelf) SuppressLint(android.annotation.SuppressLint)

Example 8 with Shelf

use of com.orgzly.android.Shelf in project orgzly-android by orgzly.

the class SyncService method onCreate.

@Override
public void onCreate() {
    if (BuildConfig.LOG_DEBUG)
        LogUtils.d(TAG);
    shelf = new Shelf(this);
    status.loadFromPreferences(this);
}
Also used : Shelf(com.orgzly.android.Shelf)

Example 9 with Shelf

use of com.orgzly.android.Shelf in project orgzly-android by orgzly.

the class BookChooserActivity method onBookClicked.

@Override
public void onBookClicked(long bookId) {
    if (action != null && action.equals(Intent.ACTION_CREATE_SHORTCUT)) {
        // Get Book by its ID
        Shelf shelf = new Shelf(this);
        Book book = shelf.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();
    }
}
Also used : Book(com.orgzly.android.Book) IconCompat(android.support.v4.graphics.drawable.IconCompat) Shelf(com.orgzly.android.Shelf) Intent(android.content.Intent) AppIntent(com.orgzly.android.AppIntent) ShortcutInfoCompat(android.support.v4.content.pm.ShortcutInfoCompat)

Example 10 with Shelf

use of com.orgzly.android.Shelf in project orgzly-android by orgzly.

the class MainActivity method onNoteScrollToRequest.

@Override
public void onNoteScrollToRequest(long noteId) {
    // 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();
        mSyncFragment.sparseTree(bookId, noteId);
        DisplayManager.displayBook(getSupportFragmentManager(), bookId, noteId);
    }
}
Also used : Note(com.orgzly.android.Note) Shelf(com.orgzly.android.Shelf)

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