Java Code Examples for android.content.Loader#getId()

The following examples show how to use android.content.Loader#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialerActivity.java    From emerald-dialer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
	int id = loader.getId();
	if (id == 0) {
		logEntryAdapter.swapCursor(data);
	} else {
		contactsEntryAdapter.setCursor(data);
	}
}
 
Example 2
Source File: DialerActivity.java    From emerald-dialer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLoaderReset(Loader<Cursor> loader) {
	int id = loader.getId();
	if (id == 0) {
		logEntryAdapter.swapCursor(null);
	} else {
		contactsEntryAdapter.setCursor(null);
	}
}
 
Example 3
Source File: HistoryActivity.java    From ActivityDiary with GNU General Public License v3.0 5 votes vote down vote up
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Swap the new cursor in.  (The framework will take care of closing the
    // old cursor once we return.)
    int i = loader.getId();
    if (i == LOADER_ID_HISTORY) {
        historyAdapter.swapCursor(data);
    } else {
        detailAdapters[i].swapCursor(data);
    }
}
 
Example 4
Source File: HistoryActivity.java    From ActivityDiary with GNU General Public License v3.0 5 votes vote down vote up
public void onLoaderReset(Loader<Cursor> loader) {
    // This is called when the last Cursor provided to onLoadFinished()
    // above is about to be closed.  We need to make sure we are no
    // longer using it.
    int i = loader.getId();
    if (i == LOADER_ID_HISTORY) {
        historyAdapter.swapCursor(null);
    } else {
        detailAdapters[i].swapCursor(null);
    }

}
 
Example 5
Source File: UserPhotosFragment.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
	switch (loader.getId()) {
	case LOADER_USER_PHOTOS_EXTERNAL:
		mPhotoAdapter.swapCursor(data);
		mPhotoGrid.setSelection(0);
		break;
	}
}
 
Example 6
Source File: EnvelopeDetailsFragment.java    From budget-envelopes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onLoadFinished(Loader<Cursor> ldr, Cursor data) {
    if (ldr.getId() == 0) {
        loadEnvelopeData(data);
    } else {
        loadLogData(data);
    }
}
 
Example 7
Source File: SalesPendingCheckoutDialogFragment.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {


    // A switch-case is useful when dealing with multiple Loader/IDs
    switch (loader.getId()) {
        case LOADER_IDE_ONE:
            // The asynchronous load is complete and the data
            // is now available for use. Only now we can associate
            // the required Cursor with the adapter.

            // Set the cursor to first position;
            data.moveToFirst();

            // Get the number of rows.
            int dataCount = data.getCount();

            // Instantiate new ArrayList<ModelMovie>
            mSalesDetailPendingList = new ArrayList<>();
            mSalesDetailPendingKeyList = new ArrayList<>();


            // Add each row into an array element.
            for (int i = 0; i < dataCount; i++) {

                SalesDetailModel model = new SalesDetailModel();
                model.setItemNumber(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_NUMBER));
                model.setItemDesc(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DESC));
                model.setItemUnit(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_UNIT));
                model.setItemPrice(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_PRICE));
                model.setItemQuantity(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_QUANTITY));
                model.setItemDiscount(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DISCOUNT));
                model.setItemDiscountAmout(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DISCOUNT_AMOUNT));
                model.setItemAmount(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_AMOUNT));

                // Pack the model into a list
                mSalesDetailPendingList.add(model);

                // Pack the key into a list
                mSalesDetailPendingKeyList.add(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_PUSH_KEY));

                // Make the cursor move to next if any
                data.moveToNext();
            }


            /**
             * Update the UI below
             */

            // calculate the number of items then update the UI
            int numberOfItems = mSalesDetailPendingList.size();
            mNumberOfItemsForm.setText(String.valueOf(numberOfItems));

    }

}
 
Example 8
Source File: OpenSalesCheckoutDialogFragment.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

    // A switch-case is useful when dealing with multiple Loader/IDs
    switch (loader.getId()) {
        case LOADER_IDE_ONE:
            // The asynchronous load is complete and the data
            // is now available for use. Only now we can associate
            // the required Cursor with the adapter.

            // Set the cursor to first position;
            data.moveToFirst();

            // Get the number of rows.
            int dataCount = data.getCount();

            // Instantiate new ArrayList<ModelMovie>
            mSalesDetailPendingList = new ArrayList<>();
            mSalesDetailPendingKeyList = new ArrayList<>();


            // Add each row into an array element.
            for (int i = 0; i < dataCount; i++) {

                SalesDetailModel model = new SalesDetailModel();
                model.setItemNumber(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_NUMBER));
                model.setItemDesc(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DESC));
                model.setItemUnit(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_UNIT));
                model.setItemPrice(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_PRICE));
                model.setItemQuantity(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_QUANTITY));
                model.setItemDiscount(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DISCOUNT));
                model.setItemDiscountAmout(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_DISCOUNT_AMOUNT));
                model.setItemAmount(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_ITEM_AMOUNT));

                // Pack the model into a list
                mSalesDetailPendingList.add(model);

                // Pack the key into a list
                mSalesDetailPendingKeyList.add(data.getString(ContractData.SalesDetailPendingEntry.INDEX_COL_PUSH_KEY));

                // Make the cursor move to next if any
                data.moveToNext();
            }


            /**
             * Update the UI below
             */

            // calculate the number of items then update the UI
            int numberOfItems = mSalesDetailPendingList.size();
            mNumberOfItemsForm.setText(String.valueOf(numberOfItems));
    }
}
 
Example 9
Source File: MiniLookupItemMaster.java    From stockita-point-of-sale with MIT License 4 votes vote down vote up
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {


    /* Get the cursor move to first. */
    cursor.moveToFirst();


    switch (loader.getId()) {
        case LOADER_ID_ONE:

            // Get the number of record in the cursor
            int dataCount = cursor.getCount();

            // Initialize local array for the item model and the item keys
            ArrayList<ItemModel> dataItemList = new ArrayList<>(dataCount);
            ArrayList<String> dataKeyList = new ArrayList<>(dataCount);

            for (int i=0; i< dataCount; i++) {

                // The item model
                ItemModel itemModel = new ItemModel();
                itemModel.setItemNumber(cursor.getString(ContractData.ItemMasterEntry.INDEX_COL_ITEM_NUMBER));
                itemModel.setItemDesc(cursor.getString(ContractData.ItemMasterEntry.INDEX_COL_ITEM_DESC));
                itemModel.setUnitOfMeasure(cursor.getString(ContractData.ItemMasterEntry.INDEX_COL_ITEM_UNIT));
                itemModel.setItemPrice(cursor.getString(ContractData.ItemMasterEntry.INDEX_COL_ITEM_PRICE));
                dataItemList.add(itemModel);

                // The push() key
                String itemPushKey = cursor.getString(ContractData.ItemMasterEntry.INDEX_COL_PUSH_KEY);
                dataKeyList.add(itemPushKey);

                // Move the cursor to next
                cursor.moveToNext();
            }

            // Initialize the adapter, then pass the two arrayList
            mMyAdapter = new MyAdapter(dataKeyList, dataItemList);

            // Set the adapter for the item master
            mItemMasterList.setAdapter(mMyAdapter);

    }

}