Example usage for android.content Loader getId

List of usage examples for android.content Loader getId

Introduction

In this page you can find the example usage for android.content Loader getId.

Prototype

public int getId() 

Source Link

Usage

From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (loader.getId() == SessionsQuery._TOKEN) {
        onSessionQueryComplete(cursor);//  www .ja  v a2s. c o  m
    } else if (loader.getId() == SpeakersQuery._TOKEN) {
        onSpeakersQueryComplete(cursor);
    } else if (loader.getId() == FeedbackQuery._TOKEN) {
        onFeedbackQueryComplete(cursor);
    } else if (loader.getId() == TAG_METADATA_TOKEN) {
        mTagMetadata = new TagMetadata(cursor);
        cursor.close();
        tryRenderTags();
    } else {
        cursor.close();
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (!isAdded()) {
        return;/*from  ww w  . ja va  2s .  co m*/
    }

    if (loader.getId() == SessionsQuery._TOKEN) {
        onSessionQueryComplete(cursor);
    } else if (loader.getId() == SpeakersQuery._TOKEN) {
        onSpeakersQueryComplete(cursor);
    } else if (loader.getId() == FeedbackQuery._TOKEN) {
        onFeedbackQueryComplete(cursor);
    } else if (loader.getId() == TAG_METADATA_TOKEN) {
        mTagMetadata = new TagMetadata(cursor);
        cursor.close();
        tryRenderTags();
    } else {
        cursor.close();
    }
}

From source file:com.app.uafeed.fragment.EntryFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (mBaseUri != null && cursor != null) { // can be null if we do a setData(null) before
        cursor.moveToFirst();/*from  w  w w.  ja v  a2  s . c o m*/

        if (mTitlePos == -1) {
            mTitlePos = cursor.getColumnIndex(EntryColumns.TITLE);
            mDatePos = cursor.getColumnIndex(EntryColumns.DATE);
            mAbstractPos = cursor.getColumnIndex(EntryColumns.ABSTRACT);
            mMobilizedHtmlPos = cursor.getColumnIndex(EntryColumns.MOBILIZED_HTML);
            mLinkPos = cursor.getColumnIndex(EntryColumns.LINK);
            mIsFavoritePos = cursor.getColumnIndex(EntryColumns.IS_FAVORITE);
            mIsReadPos = cursor.getColumnIndex(EntryColumns.IS_READ);
            mEnclosurePos = cursor.getColumnIndex(EntryColumns.ENCLOSURE);
            mAuthorPos = cursor.getColumnIndex(EntryColumns.AUTHOR);
            mFeedNamePos = cursor.getColumnIndex(FeedColumns.NAME);
            mFeedUrlPos = cursor.getColumnIndex(FeedColumns.URL);
            mFeedIconPos = cursor.getColumnIndex(FeedColumns.ICON);
        }

        int position = loader.getId();
        if (position != -1) {
            mEntryPagerAdapter.displayEntry(position, cursor, false);
        }
    }
}

From source file:com.android.mail.ui.FolderListFragment.java

@Override
public void onLoaderReset(Loader<ObjectCursor<Folder>> loader) {
    if (mFolderAdapter != null) {
        if (loader.getId() == FOLDER_LIST_LOADER_ID) {
            mFolderAdapter.setCursor(null);
        } else if (loader.getId() == ALL_FOLDER_LIST_LOADER_ID) {
            mFolderAdapter.setAllFolderListCursor(null);
        }//w  ww  .j  a v  a 2s .  c  o m
    }
}

From source file:org.cgnet.swara.fragment.EntryFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {

    if (mBaseUri != null && cursor != null) { // can be null if we do a setData(null) before
        cursor.moveToFirst();//w w  w  .j  a  v  a2 s.c  o m

        if (mTitlePos == -1) {
            mTitlePos = cursor.getColumnIndex(EntryColumns.TITLE);
            mDatePos = cursor.getColumnIndex(EntryColumns.DATE);
            mAbstractPos = cursor.getColumnIndex(EntryColumns.ABSTRACT);
            mMobilizedHtmlPos = cursor.getColumnIndex(EntryColumns.MOBILIZED_HTML);
            mLinkPos = cursor.getColumnIndex(EntryColumns.LINK);
            mIsFavoritePos = cursor.getColumnIndex(EntryColumns.IS_FAVORITE);
            mIsReadPos = cursor.getColumnIndex(EntryColumns.IS_READ);
            mEnclosurePos = cursor.getColumnIndex(EntryColumns.ENCLOSURE);
            mAuthorPos = cursor.getColumnIndex(EntryColumns.AUTHOR);
            mFeedNamePos = cursor.getColumnIndex(FeedColumns.NAME);
            mFeedUrlPos = cursor.getColumnIndex(FeedColumns.URL);
            mFeedIconPos = cursor.getColumnIndex(FeedColumns.ICON);
        }

        int position = loader.getId();
        if (position != -1) {
            mEntryPagerAdapter.displayEntry(position, cursor, false);
        }
    }
}

From source file:com.android.mail.ui.FolderListFragment.java

@Override
public void onLoadFinished(Loader<ObjectCursor<Folder>> loader, ObjectCursor<Folder> data) {
    if (mFolderAdapter != null) {
        if (loader.getId() == FOLDER_LIST_LOADER_ID) {
            mFolderAdapter.setCursor(data);

            if (mMiniDrawerEnabled) {
                mMiniDrawerView.refresh();
            }//from   www.  ja v a2s  . c  o  m

        } else if (loader.getId() == ALL_FOLDER_LIST_LOADER_ID) {
            mFolderAdapter.setAllFolderListCursor(data);
        }
    }
}

From source file:nl.privacybarometer.privacyvandaag.fragment.EntryFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (mBaseUri != null && cursor != null) { // can be null if we do a setData(null) before
        cursor.moveToFirst();/*from w  w w . ja  v  a  2 s.  c  o m*/

        if (mTitlePos == -1) {
            mTitlePos = cursor.getColumnIndex(EntryColumns.TITLE);
            mDatePos = cursor.getColumnIndex(EntryColumns.DATE);
            mAbstractPos = cursor.getColumnIndex(EntryColumns.ABSTRACT);
            mMobilizedHtmlPos = cursor.getColumnIndex(EntryColumns.MOBILIZED_HTML);
            mLinkPos = cursor.getColumnIndex(EntryColumns.LINK);
            mIsFavoritePos = cursor.getColumnIndex(EntryColumns.IS_FAVORITE);
            mIsReadPos = cursor.getColumnIndex(EntryColumns.IS_READ);
            mEnclosurePos = cursor.getColumnIndex(EntryColumns.ENCLOSURE);
            mAuthorPos = cursor.getColumnIndex(EntryColumns.AUTHOR);
            mFeedNamePos = cursor.getColumnIndex(FeedColumns.NAME);
            mFeedUrlPos = cursor.getColumnIndex(FeedColumns.URL);
            mFeedIconPos = cursor.getColumnIndex(FeedColumns.ICON);
            mIconIdPos = cursor.getColumnIndex(FeedColumns.ICON_DRAWABLE);
        }

        int position = loader.getId();
        if (position != -1) {
            mEntryPagerAdapter.displayEntry(position, cursor, false);
        }
    }
}

From source file:com.android.mail.compose.ComposeActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    int id = loader.getId();
    switch (id) {
    case INIT_DRAFT_USING_REFERENCE_MESSAGE:
        if (data != null && data.moveToFirst()) {
            mRefMessage = new Message(data);
            Intent intent = getIntent();
            initFromRefMessage(mComposeMode);
            finishSetup(mComposeMode, intent, null);
            if (mComposeMode != FORWARD) {
                String to = intent.getStringExtra(EXTRA_TO);
                if (!TextUtils.isEmpty(to)) {
                    mRefMessage.setTo(null);
                    mRefMessage.setFrom(null);
                    clearChangeListeners();
                    mTo.append(to);/*w w  w.j  a  va  2  s .c  om*/
                    initChangeListeners();
                }
            }
        } else {
            finish();
        }
        break;
    case REFERENCE_MESSAGE_LOADER:
        // Only populate mRefMessage and leave other fields untouched.
        if (data != null && data.moveToFirst()) {
            mRefMessage = new Message(data);
        }
        finishSetup(mComposeMode, getIntent(), mInnerSavedState);
        break;
    case LOADER_ACCOUNT_CURSOR:
        if (data != null && data.moveToFirst()) {
            // there are accounts now!
            Account account;
            final ArrayList<Account> accounts = new ArrayList<Account>();
            final ArrayList<Account> initializedAccounts = new ArrayList<Account>();
            do {
                account = Account.builder().buildFrom(data);
                if (account.isAccountReady()) {
                    initializedAccounts.add(account);
                }
                accounts.add(account);
            } while (data.moveToNext());
            if (initializedAccounts.size() > 0) {
                findViewById(R.id.wait).setVisibility(View.GONE);
                getLoaderManager().destroyLoader(LOADER_ACCOUNT_CURSOR);
                findViewById(R.id.compose).setVisibility(View.VISIBLE);
                mAccounts = initializedAccounts.toArray(new Account[initializedAccounts.size()]);

                finishCreate();
                invalidateOptionsMenu();
            } else {
                // Show "waiting"
                account = accounts.size() > 0 ? accounts.get(0) : null;
                showWaitFragment(account);
            }
        }
        break;
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

    if (loader.getId() == LOAD_TEMPLATE_BY_ID) {
        if (data != null && data.getCount() > 0) {
            data.moveToFirst();/*  w  ww  .ja  va2  s  . c  o m*/
            // insert template text from gesture at cursor
            String text = data.getString(data.getColumnIndex(Template.TEXT));
            int start = mTextEditor.getSelectionStart();
            int end = mTextEditor.getSelectionEnd();
            mTextEditor.getText().replace(Math.min(start, end), Math.max(start, end), text);
        }
    } else {
        setProgressBarIndeterminateVisibility(false);
        if (data != null && data.getCount() > 0) {
            showDialog(DIALOG_TEMPLATE_SELECT);
            mTemplatesCursorAdapter.swapCursor(data);
        } else {
            showDialog(DIALOG_TEMPLATE_NOT_AVAILABLE);
        }
    }
}