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:com.deange.textfaker.ui.activity.MessageActivity.java

@Override
public void onLoadFinished(final Loader<Cursor> cursorLoader, final Cursor cursor) {
    Log.v(TAG, "onLoadFinished()");

    final int loaderId = cursorLoader.getId();
    if (loaderId == LOADER_CONVERSATION_MESSAGES_ID) {
        mAdapter.swapCursor(cursor);//from  w w  w  .j a v  a2  s . c  om

    } else if (loaderId == LOADER_CONVERSATION_ID) {
        mConversation = new Conversation(cursor);
        setupActionBar();
    }
}

From source file:com.money.manager.ex.investment.watchlist.WatchlistItemsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    switch (loader.getId()) {
    case ID_LOADER:
        // send the data to the view adapter.
        StocksCursorAdapter adapter = (StocksCursorAdapter) getListAdapter();
        adapter.changeCursor(data);/*  w ww  .  ja v  a 2 s .  c om*/

        if (isResumed()) {
            setListShown(true);

            if (getFloatingActionButton() != null) {
                getFloatingActionButton().show(true);
            }
        } else {
            setListShownNoAnimation(true);
        }
        // update the header
        displayHeaderData();
    }
}

From source file:com.customprogrammingsolutions.MediaStreamer.MainActivity.java

@Override
public void onLoaderReset(Loader<Cursor> loader) {
    if (loader.getId() == 0) {
        recentsAdapter.swapCursor(null);
    } else if (loader.getId() == 1) {
        favoritesAdapter.swapCursor(null);
    }//from   w  w w.  ja v  a  2s  . c om
}

From source file:edu.mit.mobile.android.locast.itineraries.ItineraryDetail.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
    switch (loader.getId()) {
    case LOADER_ITINERARY: {
        displayItinerary(loader, c);/*www . j  a  va 2s.c om*/
    }
        break;

    case LOADER_CASTS: {
        mCastAdapter.swapCursor(c);
        if (USE_MAP) {
            mCastsOverlay.swapCursor(c);
        }
        // this is done after the casts are loaded so that an expedited sync can be
        // requested if the list is empty.
        if (mFirstLoadSync) {
            refresh(false);
            mFirstLoadSync = false;
        }
    }
        break;
    }
}

From source file:cz.maresmar.sfm.view.menu.MenuDetailsFragment.java

@Override
public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor cursor) {
    switch (loader.getId()) {
    case MENU_LOADER_ID: {
        Timber.d("Menu data loaded");

        if (BuildConfig.DEBUG) {
            Assert.isOne(cursor.getCount());
        }/*from  w w w  . j  a  va 2s.co  m*/

        cursor.moveToFirst();

        @ProviderContract.MenuStatus
        int status = cursor.getInt(0);
        @ProviderContract.PortalFeatures
        int features = cursor.getInt(1);

        // Menu detail text
        final long rawDate = cursor.getLong(2);
        mDateText.setText(MenuUtils.getDateStr(mDateText.getContext(), rawDate));
        final int rawPrice = cursor.getInt(3);
        mPriceText.setText(MenuUtils.getPriceStr(mPriceText.getContext(), rawPrice));
        mTextText.setText(cursor.getString(4));
        mPortalName.setText(cursor.getString(5));

        // Taken amount handling
        mSyncedTaken = cursor.getInt(12);
        mTakenAmountText.setText(String.valueOf(mSyncedTaken));

        // Amount table
        // Synced
        mSyncedReserved = cursor.getInt(6);
        int syncedOffered = cursor.getInt(7);

        mSyncedReservedText.setText(String.valueOf(mSyncedReserved));
        if ((status & ProviderContract.MENU_STATUS_CANCELABLE) == ProviderContract.MENU_STATUS_CANCELABLE) {
            mMinReserved = mSyncedTaken;
        } else {
            mMinReserved = mSyncedReserved;
        }
        mSyncedOfferedText.setText(String.valueOf(syncedOffered));

        int reserved = mSyncedReserved;
        int offered = syncedOffered;

        // To sync
        if (!cursor.isNull(8)) {
            reserved = cursor.getInt(8);
            offered = cursor.getInt(9);
            mToSyncReservedText.setText(String.valueOf(reserved));
            mToSyncOfferedText.setText(String.valueOf(offered));
        } else {
            mToSyncReservedText.setText(R.string.menu_detail_empty);
            mToSyncOfferedText.setText(R.string.menu_detail_empty);
        }
        // Change
        if (!cursor.isNull(10)) {
            reserved = cursor.getInt(10);
            offered = cursor.getInt(11);
        }
        mChangedReservedEditText.setText(String.valueOf(reserved));
        mChangedOfferedEditText.setText(String.valueOf(offered));

        // To take handling
        final int toTake = cursor.getInt(13);
        if (toTake != ProviderContract.NO_INFO) {
            mToTakeText.setText(String.valueOf(toTake));
            mToTakeGroup.setVisibility(View.VISIBLE);
        } else {
            mToTakeText.setText(R.string.menu_detail_not_available);
            mToTakeGroup.setVisibility(View.GONE);
        }

        // To order handling
        final int toOrder = cursor.getInt(14);
        if (toOrder != ProviderContract.NO_INFO) {
            mToOrderText.setText(String.valueOf(Math.max(0, toOrder - syncedOffered)));
            if ((features
                    & ProviderContract.FEATURE_MULTIPLE_ORDERS) == ProviderContract.FEATURE_MULTIPLE_ORDERS) {
                mMaxReserved = mSyncedReserved + Math.max(0, toOrder - syncedOffered);
            } else {
                mMaxReserved = Math.min(1, mSyncedReserved + Math.max(0, toOrder - syncedOffered));
            }
        } else {
            if ((status & ProviderContract.MENU_STATUS_ORDERABLE) == ProviderContract.MENU_STATUS_ORDERABLE) {
                mToOrderText.setText(R.string.menu_detail_unlimited);
                if ((features
                        & ProviderContract.FEATURE_MULTIPLE_ORDERS) == ProviderContract.FEATURE_MULTIPLE_ORDERS) {
                    mMaxReserved = Integer.MAX_VALUE;
                } else {
                    mMaxReserved = 1;
                }
            } else {
                mToOrderText.setText("0");
                mMaxReserved = mSyncedReserved;
            }
        }

        // Last change
        final long rawLastChange = cursor.getLong(15);
        if (rawLastChange != ProviderContract.NO_INFO) {
            mLastChangeText.setText(MenuUtils.getDateTimeStr(mLastChangeText.getContext(), rawLastChange));
        } else {
            mLastChangeText.setText(R.string.menu_detail_not_available);
        }

        // Reserved change button
        if (rawDate >= MenuUtils.getTodayDate()) {
            mChangedReservedEditText.setEnabled(mMinReserved != mMaxReserved);
        } else {
            mChangedReservedEditText.setEnabled(false);
        }

        // Offer change button
        if ((status & ProviderContract.FEATURE_FOOD_STOCK) == ProviderContract.FEATURE_FOOD_STOCK) {
            mChangedOfferedEditText.setEnabled(rawDate >= MenuUtils.getTodayDate() && 0 != mSyncedReserved);
            mOfferGroup.setVisibility(View.VISIBLE);
        } else {
            mChangedOfferedEditText.setEnabled(false);
            mOfferGroup.setVisibility(View.INVISIBLE);
        }

        // Label
        getActivity().setTitle(cursor.getString(16));

        break;
    }
    default:
        throw new UnsupportedOperationException("Unknown loader id: " + loader.getId());
    }
}

From source file:net.niyonkuru.koodroid.ui.UsageFragment.java

@Override
public void onLoaderReset(Loader<Cursor> loader) {
    int id = loader.getId();

    switch (id) {
    case AIRTIME_TOKEN:
        mAirtimeUpdateTime.setText(null);
        break;//from w w  w .  j  av a 2s . co  m
    case DATA_TOKEN:
    case TEXT_TOKEN:
        mDataUpdatedTime.setText(null);
        break;
    }
}

From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatList.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    /* A switch-case is useful when dealing with multiple Loaders/IDs */
    switch (loader.getId()) {
    case LOADER_ID:
        /*//w ww.j av a 2 s .com
         * The asynchronous load is complete and the data is now available for use. Only now
         * can we associate the queried Cursor with the CursorAdapter.
         */
        mAdapter.swapCursor(cursor);
        break;
    }
    /* The listview now displays the queried data. */
}

From source file:com.andrada.sitracker.ui.fragment.RemoteAuthorsFragment.java

@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override/*from   www .  ja v a  2 s  .co m*/
public void onLoadFinished(Loader<AsyncTaskResult<List<SearchedAuthor>>> loader,
        AsyncTaskResult<List<SearchedAuthor>> data) {
    if (getActivity() == null) {
        return;
    }

    int token = loader.getId();
    LOGD(TAG, "Loader finished: search");
    if (token == SamlibSearchLoader.SEARCH_TOKEN) {
        if (data.getError() instanceof SearchException) {
            int errorMsg;
            switch (((SearchException) data.getError()).getError()) {
            case SAMLIB_BUSY:
                errorMsg = R.string.cannot_search_busy;
                break;
            case NETWORK_ERROR:
                errorMsg = R.string.cannot_search_network;
                break;
            case INTERNAL_ERROR:
                errorMsg = R.string.cannot_search_internal;
                break;
            default:
                errorMsg = R.string.cannot_search_unknown;
                break;
            }
            Style.Builder alertStyle = new Style.Builder().setTextAppearance(android.R.attr.textAppearanceLarge)
                    .setPaddingInPixels(25).setBackgroundColorValue(Style.holoRedLight);
            Crouton.makeText(getActivity(), getString(errorMsg), alertStyle.build()).show();
        }
        updateCollectionView(data.getResult());
    }
}

From source file:com.customprogrammingsolutions.MediaStreamer.MainActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
    if (loader.getId() == 0) {
        recentsAdapter.swapCursor(c);//from  w w w.j a  v a  2s  .co  m
    } else if (loader.getId() == 1) {
        favoritesAdapter.swapCursor(c);
    }
}

From source file:com.gvccracing.android.tttimer.Tabs.RaceInfoTab.java

public void onLoaderReset(Loader<Cursor> loader) {
    try {/*from   w ww .j a  v  a2s  . c  om*/
        Log.i(LOG_TAG(), "onLoaderReset start: id=" + Integer.toString(loader.getId()));
        switch (loader.getId()) {
        case RACE_INFO_LOADER:
            break;
        case APP_SETTINGS_LOADER_RACEINFO:
            break;
        case COURSE_RECORD_LOADER:
            break;
        }
        Log.i(LOG_TAG(), "onLoaderReset complete: id=" + Integer.toString(loader.getId()));
    } catch (Exception ex) {
        Log.e(LOG_TAG(), "onLoaderReset error", ex);
    }
}