Example usage for android.support.v4.content Loader getId

List of usage examples for android.support.v4.content Loader getId

Introduction

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

Prototype

public int getId() 

Source Link

Usage

From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    switch (loader.getId()) {
    case LOADER_EPG:
        refresh(LOADER_CHANNELLIST);//from  w  w w .  j a  v  a  2  s .c o  m
        break;
    case LOADER_REFRESH_CHANNELLIST:
        /**
         * Prfung ob das EPG in der Senderliste angezeigt werden soll.
         */
        if ((showNowPlaying && !showNowPlayingWifi)
                || (showNowPlaying && showNowPlayingWifi && mNetworkInfo.isConnected())) {
            refresh(LOADER_EPG);
        } else {
            refresh(LOADER_CHANNELLIST);
        }
        break;
    default:
        mAdapter.swapCursor(cursor);
        if (selectedPosition != ListView.INVALID_POSITION) {
            getListView().setItemChecked(selectedPosition, true);
        }
        getListView().setSelectionFromTop(selectedPosition,
                (int) getResources().getDimension(R.dimen.list_preferred_item_height_small) * 3);
        setListShown(true);
        break;
    }
    getSherlockActivity().invalidateOptionsMenu();
}

From source file:com.purdue.CampusFeed.Activities.ContactDetailFragment.java

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

    // If this fragment was cleared while the query was running
    // eg. from from a call like setContact(uri) then don't do
    // anything.// w  w  w  . jav a2  s .  c om
    if (mContactUri == null) {
        return;
    }

    switch (loader.getId()) {
    case ContactDetailQuery.QUERY_ID:
        // Moves to the first row in the Cursor
        if (data.moveToFirst()) {
            // For the contact details query, fetches the contact display name.
            // ContactDetailQuery.DISPLAY_NAME maps to the appropriate display
            // name field based on OS version.
            final String contactName = data.getString(ContactDetailQuery.DISPLAY_NAME);
            if (mIsTwoPaneLayout && mContactName != null) {
                // In the two pane layout, there is a dedicated TextView
                // that holds the contact name.
                mContactName.setText(contactName);
            } else {
                // In the single pane layout, sets the activity title
                // to the contact name. On HC+ this will be set as
                // the ActionBar title text.
                getActivity().setTitle(contactName);
            }
        }
        break;
    case ContactAddressQuery.QUERY_ID:
        // This query loads the contact address details. More than
        // one contact address is possible, so move each one to a
        // LinearLayout in a Scrollview so multiple addresses can
        // be scrolled by the user.

        // Each LinearLayout has the same LayoutParams so this can
        // be created once and used for each address.
        /*
        final LinearLayout.LayoutParams layoutParams =
                new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT);
                
        // Clears out the details layout first in case the details
        // layout has addresses from a previous data load still
        // added as children.
        mDetailsLayout.removeAllViews();
                
        // Loops through all the rows in the Cursor
        if (data.moveToFirst()) {
            do {
                // Builds the address layout
                final LinearLayout layout = buildAddressLayout(
                        data.getInt(ContactAddressQuery.TYPE),
                        data.getString(ContactAddressQuery.LABEL),
                        data.getString(ContactAddressQuery.ADDRESS));
                // Adds the new address layout to the details layout
                mDetailsLayout.addView(layout, layoutParams);
            } while (data.moveToNext());
        } else {
            // If nothing found, adds an empty address layout
            mDetailsLayout.addView(buildEmptyAddressLayout(), layoutParams);
        }*/
        break;
    case ContactPhoneQuery.QUERY_ID:

        ContactDetailFragment.contactPhoneNumbers.clear();

        final LinearLayout.LayoutParams layoutParameters = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        // Clears out the details layout first in case the details
        // layout has addresses from a previous data load still
        // added as children.
        mDetailsLayout.removeAllViews();

        // Loops through all the rows in the Cursor
        if (data.moveToFirst()) {
            do {
                // Builds the address layout
                String contactPhoneNumber = data.getString(ContactPhoneQuery.PHONE_NUMBER);
                ContactDetailFragment.contactPhoneNumbers.add(contactPhoneNumber);

                final LinearLayout layout = buildAddressLayout(contactPhoneNumber);
                // Adds the new address layout to the details layout
                mDetailsLayout.addView(layout, layoutParameters);

                ImageButton button = (ImageButton) mDetailsLayout
                        .findViewById(R.id.contact_detail_item_sms_button);
                button.setVisibility(View.VISIBLE);

            } while (data.moveToNext());

        } else {
            // If nothing found, adds an empty address layout
            mDetailsLayout.addView(buildEmptyAddressLayout(), layoutParameters);

            ImageButton button = (ImageButton) mDetailsLayout.findViewById(R.id.contact_detail_item_sms_button);
            button.setVisibility(View.INVISIBLE);
        }

        break;
    }
}

From source file:org.totschnig.myexpenses.fragment.TransactionList.java

@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
    switch (arg0.getId()) {
    case TRANSACTION_CURSOR:
        mTransactionsCursor = c;/*from   w w  w . ja v  a 2 s . c o m*/
        hasItems = c.getCount() > 0;
        if (!indexesCalculated) {
            columnIndexYear = c.getColumnIndex(KEY_YEAR);
            columnIndexYearOfWeekStart = c.getColumnIndex(KEY_YEAR_OF_WEEK_START);
            columnIndexYearOfMonthStart = c.getColumnIndex(KEY_YEAR_OF_MONTH_START);
            columnIndexMonth = c.getColumnIndex(KEY_MONTH);
            columnIndexWeek = c.getColumnIndex(KEY_WEEK);
            columnIndexDay = c.getColumnIndex(KEY_DAY);
            columnIndexLabelSub = c.getColumnIndex(KEY_LABEL_SUB);
            columnIndexLabelMain = c.getColumnIndex(KEY_LABEL_MAIN);
            columnIndexPayee = c.getColumnIndex(KEY_PAYEE_NAME);
            columnIndexCrStatus = c.getColumnIndex(KEY_CR_STATUS);
            indexesCalculated = true;
        }
        mAdapter.swapCursor(c);
        invalidateCAB();
        break;
    case SUM_CURSOR:
        c.moveToFirst();
        mappedCategories = c.getInt(c.getColumnIndex(KEY_MAPPED_CATEGORIES)) > 0;
        mappedPayees = c.getInt(c.getColumnIndex(KEY_MAPPED_PAYEES)) > 0;
        mappedMethods = c.getInt(c.getColumnIndex(KEY_MAPPED_METHODS)) > 0;
        hasTransfers = c.getInt(c.getColumnIndex(KEY_HAS_TRANSFERS)) > 0;
        getActivity().supportInvalidateOptionsMenu();
        break;
    case GROUPING_CURSOR:
        mGroupingCursor = c;
        //if the transactionscursor has been loaded before the grouping cursor, we need to refresh
        //in order to have accurate grouping values
        if (!indexesGroupingCalculated) {
            columnIndexGroupYear = c.getColumnIndex(KEY_YEAR);
            columnIndexGroupSecond = c.getColumnIndex(KEY_SECOND_GROUP);
            columnIndexGroupSumIncome = c.getColumnIndex(KEY_SUM_INCOME);
            columnIndexGroupSumExpense = c.getColumnIndex(KEY_SUM_EXPENSES);
            columnIndexGroupSumTransfer = c.getColumnIndex(KEY_SUM_TRANSFERS);
            columnIndexGroupMappedCategories = c.getColumnIndex(KEY_MAPPED_CATEGORIES);
            columnIndexGroupSumInterim = c.getColumnIndex(KEY_INTERIM_BALANCE);
            indexesGroupingCalculated = true;
        }
        if (mTransactionsCursor != null)
            mAdapter.notifyDataSetChanged();
    }
}

From source file:com.tct.fw.ex.photo.fragments.PhotoViewFragment.java

@Override
public void onLoadFinished(Loader<BitmapResult> loader, BitmapResult result) {
    // If we don't have a view, the fragment has been paused. We'll get the cursor again later.
    // If we're not added, the fragment has detached during the loading process. We no longer
    // need the result.
    if (getView() == null || !isAdded()) {
        return;/*from   w  w w .  ja va  2  s .  co m*/
    }

    final Drawable data = result.getDrawable(getResources());

    final int id = loader.getId();
    switch (id) {
    case PhotoViewCallbacks.BITMAP_LOADER_THUMBNAIL:
        if (mDisplayThumbsFullScreen) {
            displayPhoto(result);
        } else {
            if (isPhotoBound()) {
                // There is need to do anything with the thumbnail
                // image, as the full size image is being shown.
                return;
            }

            if (data == null) {
                // no preview, show default
                mPhotoPreviewImage.setImageResource(R.drawable.default_image);
                mThumbnailShown = false;
            } else {
                // show preview
                mPhotoPreviewImage.setImageDrawable(data);
                mThumbnailShown = true;
            }
            mPhotoPreviewImage.setVisibility(View.VISIBLE);
            if (getResources().getBoolean(R.bool.force_thumbnail_no_scaling)) {
                mPhotoPreviewImage.setScaleType(ImageView.ScaleType.CENTER);
            }
            enableImageTransforms(false);
        }
        break;

    case PhotoViewCallbacks.BITMAP_LOADER_PHOTO:
        displayPhoto(result);
        break;
    default:
        break;
    }

    if (mProgressBarNeeded == false) {
        // Hide the progress bar as it isn't needed anymore.
        mPhotoProgressBar.setVisibility(View.GONE);
    }

    if (data != null) {
        mCallback.onNewPhotoLoaded(mPosition);
    }
    setViewVisibility();
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.MapFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (getActivity() == null) {
        return;/*from   w  w w  .  j  av  a2  s.c  om*/
    }
    switch (loader.getId()) {
    case MarkerQuery._TOKEN:
        onMarkerLoaderComplete(cursor);
        break;
    case OverlayQuery._TOKEN:
        onOverlayLoaderComplete(cursor);
        break;
    case TracksQuery._TOKEN:
        onTracksLoaderComplete(cursor);
        break;
    }
}

From source file:net.ddns.mlsoftlaberge.contactslist.ui.ContactsBudgetFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // If this fragment was cleared while the query was running
    // eg. from from a call like setContact(uri) then don't do
    // anything./*from   ww  w  . j a  v a  2 s .  com*/
    if (mContactUri == null) {
        return;
    }
    if (data == null) {
        return;
    }
    // collect datas depending on the loader id
    switch (loader.getId()) {
    case ContactDetailQuery.QUERY_ID:
        // Moves to the first row in the Cursor
        if (data.moveToFirst()) {
            do {
                String contactid = data.getString(ContactDetailQuery.ID);
                String rawcontactid = data.getString(ContactDetailQuery.RAWID);
                String contactName = data.getString(ContactDetailQuery.DISPLAY_NAME);
                // place the datas in the clients table
                int clientno = getClient(rawcontactid);
                clientslist[clientno].name = contactName;
                clientslist[clientno].rawid = rawcontactid;
            } while (data.moveToNext());
        }
        nbloaders++;
        break;
    case ContactAddressQuery.QUERY_ID:
        // This query loads the contact address .
        if (data.moveToFirst()) {
            do {
                // Builds the address layout
                String contactid = data.getString(ContactAddressQuery.ID);
                String rawcontactid = data.getString(ContactAddressQuery.RAWID);
                int addrtype = data.getInt(ContactAddressQuery.TYPE);
                String addrlabel = data.getString(ContactAddressQuery.LABEL);
                String addrdata = data.getString(ContactAddressQuery.ADDRESS);
                // Gets postal address label type
                CharSequence alabel = StructuredPostal.getTypeLabel(getResources(), addrtype, addrlabel);
                // place the datas in the clients table
                int clientno = getClient(rawcontactid);
                clientslist[clientno].address = addrdata;
                clientslist[clientno].addresstypelabel = alabel.toString();
            } while (data.moveToNext());
        }
        nbloaders++;
        break;
    case ContactPhoneQuery.QUERY_ID:
        // This query loads the contact phone
        if (data.moveToFirst()) {
            do {
                String contactid = data.getString(ContactPhoneQuery.ID);
                String rawcontactid = data.getString(ContactPhoneQuery.RAWID);
                int phonetype = data.getInt(ContactPhoneQuery.TYPE);
                String phonelabel = data.getString(ContactPhoneQuery.LABEL);
                String phonedata = data.getString(ContactPhoneQuery.PHONE);
                // Gets phone label type
                CharSequence plabel = android.provider.ContactsContract.CommonDataKinds.Phone
                        .getTypeLabel(getResources(), phonetype, phonelabel);
                // place the datas in the clients table
                int clientno = getClient(rawcontactid);
                clientslist[clientno].phone = phonedata;
                clientslist[clientno].phonetypelabel = plabel.toString();
            } while (data.moveToNext());
        }
        nbloaders++;
        break;
    case ContactEmailQuery.QUERY_ID:
        // This query loads the contact email
        if (data.moveToFirst()) {
            do {
                String contactid = data.getString(ContactEmailQuery.ID);
                String rawcontactid = data.getString(ContactEmailQuery.RAWID);
                int emailtype = data.getInt(ContactEmailQuery.TYPE);
                String emaillabel = data.getString(ContactEmailQuery.LABEL);
                String emaildata = data.getString(ContactEmailQuery.EMAIL);
                // Gets email label type
                CharSequence elabel = android.provider.ContactsContract.CommonDataKinds.Email
                        .getTypeLabel(getResources(), emailtype, emaillabel);
                // place the datas in the clients table
                int clientno = getClient(rawcontactid);
                clientslist[clientno].email = emaildata;
                clientslist[clientno].emailtypelabel = elabel.toString();
            } while (data.moveToNext());
        }
        nbloaders++;
        break;
    case ContactNotesQuery.QUERY_ID:
        // This query loads the contact notes
        // Get the first row of the cursor (table contains only one row)
        if (data.moveToFirst()) {
            do {
                String contactid = data.getString(ContactNotesQuery.ID);
                String rawcontactid = data.getString(ContactNotesQuery.RAWID);
                String notesdata = data.getString(ContactNotesQuery.NOTE);
                // place the datas in the clients table
                int clientno = getClient(rawcontactid);
                expandnote(clientno, notesdata);
            } while (data.moveToNext());
        }
        nbloaders++;
        break;
    }
    // when all loaders are finished, then display the contents
    if (nbloaders >= 5) {
        filltransactionlayout();
    }

}

From source file:com.example.android.contactslist.ui.chartActivity.ContactDetailChartFragment.java

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

    // If this fragment was cleared while the query was running
    // eg. from from a call like setContact(uri) then don't do
    // anything.//from  ww  w . j  a v  a2  s. c  om
    if (mContactUri == null) {
        return;
    }

    switch (loader.getId()) {
    case ContactDetailQuery.QUERY_ID:
        // Moves to the first row in the Cursor
        if (data.moveToFirst()) {
            // For the contact details query, fetches the contact display name.
            // ContactDetailQuery.DISPLAY_NAME maps to the appropriate display
            // name field based on OS version.
            mContactNameString = data.getString(ContactDetailQuery.DISPLAY_NAME);
            if (mIsTwoPaneLayout && mContactNameView != null) {
                // In the two pane layout, there is a dedicated TextView
                // that holds the contact name.
                mContactNameView.setText(mContactNameString);
            } else {
                // In the single pane layout, sets the activity title
                // to the contact name. On HC+ this will be set as
                // the ActionBar title text.
                getActivity().setTitle(mContactNameString);
            }

            loadChartView();
        }
        break;

    case ContactStatsQuery.QUERY_ID:

        setContactStatsFromCursor(data);
        if (mContactStats != null) {

            // put the stats up on display

        }
        break;
    }
}

From source file:cz.maresmar.sfm.view.MainActivity.java

@Override
public void onLoaderReset(@NonNull Loader<Cursor> loader) {
    switch (loader.getId()) {
    case USER_LOADER_ID:
        Timber.e("User data is no longer valid");

        // Removes old profiles
        mProfiles.clear();//w  ww.ja v  a  2 s.co m
        mSelectedUserId = SettingsContract.LAST_USER_UNKNOWN;

        // Insert helping entries
        mProfiles.addProfiles(ADD_USER_DRAWER_ITEM, MANAGE_USER_DRAWER_ITEM);

        break;
    case PORTAL_LOADER_ID: {
        Timber.e("Portal data with user %d is no longer valid", mSelectedUserId);

        // Clear old portals
        int oldPortalCount = mPortalDrawerItem.getSubItems().size();
        mPortalDrawerItem.getSubItems().clear();

        // Insert control entries
        mPortalDrawerItem.withSubItems(ADD_PORTAL_DRAWER_ITEM, MANAGE_PORTAL_DRAWER_ITEM);

        // Notify about changes
        if (mPortalDrawerItem.isExpanded()) {
            mDrawer.getExpandableExtension()
                    .notifyAdapterSubItemsChanged(mDrawer.getPosition(mPortalDrawerItem), oldPortalCount);
        }
        break;
    }
    case CREDENTIAL_LOADER_ID:
        Timber.e("Credential data with user %d is no longer valid", mSelectedUserId);
        mProfiles.getActiveProfile().withEmail(null);
        mProfiles.updateProfile(mProfiles.getActiveProfile());
        break;
    case EDIT_ACTIONS_COUNT_LOADER_ID:
        Timber.e("Actions data with user %d is no longer valid", mSelectedUserId);
        setMenuEditUiShown(false);
        break;
    default:
        throw new UnsupportedOperationException("Unknown loader id: " + loader.getId());
    }
}

From source file:com.nononsenseapps.feeder.ui.FeedFragment.java

@Override
public void onLoaderReset(final Loader cursorLoader) {
    if (FEEDITEMS_LOADER == cursorLoader.getId()) {
        Log.d(TAG, "onLoaderReset FeedItem");
        //mAdapter.swapCursor(null);
    }//  ww  w . ja  va  2s  .  c  o  m
}

From source file:mobisocial.musubi.ui.fragments.FeedListFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    mFeeds.changeCursor(loader.getId(), cursor);
    /*if (cursor.moveToFirst()) {
    long feedId = cursor.getLong(cursor.getColumnIndexOrThrow(MFeed.COL_ID));
    final Uri feedUri = MusubiContentProvider.uriForItem(Provided.FEEDS, feedId);
    if (getArguments() != null && getArguments().containsKey(DUAL_PANE) && isAdded()) {
        new Handler(getActivity().getMainLooper()).post(new Runnable() {
            @Override/*from   w  w w  . j  a  v a  2s.  c  o m*/
            public void run() {
                selectFeed(0, feedUri);
            }
        });
    }
    }*/
}