List of usage examples for android.support.v4.content Loader getId
public int getId()
From source file:org.sufficientlysecure.keychain.ui.EditKeyFragment.java
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.) switch (loader.getId()) { case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(data); break;/*from w w w . ja v a 2s.c om*/ case LOADER_ID_SUBKEYS: mSubkeysAdapter.swapCursor(data); break; } }
From source file:com.money.manager.ex.fragment.AllDataFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (getSearResultFragmentLoaderCallbacks() != null) { getSearResultFragmentLoaderCallbacks().onCallbackLoaderFinished(loader, data); }/*ww w .jav a2 s . com*/ switch (loader.getId()) { case ID_LOADER_ALL_DATA_DETAIL: ((CursorAdapter) getListAdapter()).swapCursor(data); if (isResumed()) { setListShown(true); } else { setListShownNoAnimation(true); } } }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { MainActivity mainActivity = null;/*from ww w . j a v a2 s .com*/ if (getActivity() != null && getActivity() instanceof MainActivity) mainActivity = (MainActivity) getActivity(); switch (loader.getId()) { case ID_LOADER_USER_NAME: if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { String infoValue = data.getString(data.getColumnIndex(infoTable.INFONAME)); // save into preferences username and basecurrency id if (Constants.INFOTABLE_USERNAME.equalsIgnoreCase(infoValue)) { application.setUserName(data.getString(data.getColumnIndex(infoTable.INFOVALUE))); } else if (Constants.INFOTABLE_BASECURRENCYID.equalsIgnoreCase(infoValue)) { //application.setBaseCurrencyId(data.getInt(data.getColumnIndex(infoTable.INFOVALUE))); } data.moveToNext(); } } // show username if (!TextUtils.isEmpty(application.getUserName())) ((SherlockFragmentActivity) getActivity()).getSupportActionBar() .setSubtitle(application.getUserName()); // set user name on drawer if (mainActivity != null) mainActivity.setDrawableUserName(application.getUserName()); break; case ID_LOADER_ACCOUNT_BILLS: double curTotal = 0, curReconciled = 0; AccountBillsAdapter adapter = null; linearHome.setVisibility(data != null && data.getCount() > 0 ? View.VISIBLE : View.GONE); linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); // cycle cursor if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { curTotal += data.getDouble(data.getColumnIndex(QueryAccountBills.TOTALBASECONVRATE)); curReconciled += data.getDouble(data.getColumnIndex(QueryAccountBills.RECONCILEDBASECONVRATE)); data.moveToNext(); } // create adapter adapter = new AccountBillsAdapter(getActivity(), data); } // write accounts total txtTotalAccounts.setText(currencyUtils.getBaseCurrencyFormatted(curTotal)); // manage footer listview if (linearFooter == null) { linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills, null); // textview into layout txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountTotal); txtFooterSummaryReconciled = (TextView) linearFooter .findViewById(R.id.textVievItemAccountTotalReconciled); // set text TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountName); txtTextSummary.setText(R.string.summary); // invisibile image ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType); imgSummary.setVisibility(View.INVISIBLE); // set color textview txtTextSummary.setTextColor(Color.GRAY); txtFooterSummary.setTextColor(Color.GRAY); txtFooterSummaryReconciled.setTextColor(Color.GRAY); } // remove footer lstAccountBills.removeFooterView(linearFooter); // set text txtFooterSummary.setText(txtTotalAccounts.getText()); txtFooterSummaryReconciled.setText(currencyUtils.getBaseCurrencyFormatted(curReconciled)); // add footer lstAccountBills.addFooterView(linearFooter, null, false); // set adapter and shown lstAccountBills.setAdapter(adapter); setListViewAccountBillsVisible(true); // set total accounts in drawer if (mainActivity != null) { mainActivity.setDrawableTotalAccounts(txtTotalAccounts.getText().toString()); } break; case ID_LOADER_BILL_DEPOSITS: mainActivity.setDrawableRepeatingTransactions(data != null ? data.getCount() : 0); break; case ID_LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null && data.moveToFirst()) { while (!data.isAfterLast()) { expenses = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Expenses)); income = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Income)); //move to next record data.moveToNext(); } } TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference); // set value if (txtIncome != null) txtIncome.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income)); if (txtExpenses != null) txtExpenses.setText( currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), Math.abs(expenses))); if (txtDifference != null) txtDifference.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income - Math.abs(expenses))); // manage progressbar final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome); final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses); if (barIncome != null && barExpenses != null) { barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses))); barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses))); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress", (int) Math.abs(income)); animationIncome.setDuration(1000); // 0.5 second animationIncome.setInterpolator(new DecelerateInterpolator()); animationIncome.start(); ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress", (int) Math.abs(expenses)); animationExpenses.setDuration(1000); // 0.5 second animationExpenses.setInterpolator(new DecelerateInterpolator()); animationExpenses.start(); } else { barIncome.setProgress((int) Math.abs(income)); barExpenses.setProgress((int) Math.abs(expenses)); } } } }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.common.NavigationDrawerFragment.java
/** * @param loader The Loader that has finished. * @param c The data generated by the Loader. */// w ww . j ava 2s. co m @Override public void onLoadFinished(Loader<Cursor> loader, Cursor c) { switch (loader.getId()) { case LOADER_NAVDRAWER_LISTS: mAdapter.setData(c); break; } }
From source file:org.cyanogenmod.theme.chooser.ChooserDetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { int id = cursorLoader.getId(); if (id == LOADER_ID_THEME_INFO) { if (cursor.getCount() == 0) { //Theme was deleted safelyPopStack();/* ww w . ja v a 2 s . c om*/ } else { loadThemeInfo(cursor); } } else if (id == LOADER_ID_APPLIED_THEME) { loadAppliedInfo(cursor); } }
From source file:com.syncedsynapse.kore2.ui.MovieDetailsFragment.java
/** {@inheritDoc} */ @Override/* w ww .jav a 2s .c om*/ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { if (cursor != null && cursor.getCount() > 0) { switch (cursorLoader.getId()) { case LOADER_MOVIE: displayMovieDetails(cursor); checkOutdatedMovieDetails(cursor); break; case LOADER_CAST: displayCastList(cursor); break; } } }
From source file:edu.mit.mobile.android.livingpostcards.CameraActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor c) { switch (loader.getId()) { case LOADER_CARD: if (c.moveToFirst()) { setTitle(Card.getTitle(this, c)); }//from w w w . j a v a 2 s . c o m break; case LOADER_CARDMEDIA: showLastPhoto(c); break; } }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { switch (loader.getId()) { case R.id.loader_narratives_completed: mNarrativeAdapter.swapCursor(cursor); break;//from w w w . j a va2 s. c o m } }
From source file:li.barter.fragments.BooksAroundMeFragment.java
@Override public void onLoaderReset(final Loader<Cursor> loader) { if (loader.getId() == Loaders.SEARCH_BOOKS) { mBooksAroundMeAdapter.swapCursor(null); }//from w w w. jav a 2 s . c o m }
From source file:com.money.manager.ex.common.CategoryListFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { switch (loader.getId()) { case ID_LOADER_CATEGORYSUB: setListAdapter(getAdapter(data)); if (isResumed()) { setListShown(true);//from w ww . ja va 2 s .co m boolean noData = data == null || data.getCount() <= 0; if (noData && getFloatingActionButton() != null) { getFloatingActionButton().show(true); } } else { setListShownNoAnimation(true); } for (int i = 0; i < mPositionToExpand.size(); i++) { getExpandableListView().expandGroup(mPositionToExpand.get(i)); } } }