List of usage examples for android.support.v4.content Loader getId
public int getId()
From source file:org.sufficientlysecure.keychain.ui.CertifyKeyActivity.java
@Override public void onLoaderReset(Loader<Cursor> loader) { switch (loader.getId()) { case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(null); break;/*from w w w. j av a2 s . c o m*/ } }
From source file:org.sufficientlysecure.keychain.ui.keyview.LinkedIdViewFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { switch (loader.getId()) { case LOADER_ID_LINKED_ID: // Nothing to load means break if we are *expected* to load if (!cursor.moveToFirst()) { // Or just ignore, this is probably some intermediate state during certify break; }//from w ww . j av a2s . c o m try { int certStatus = cursor.getInt(UserIdsAdapter.INDEX_VERIFIED); byte[] data = cursor.getBlob(UserIdsAdapter.INDEX_ATTRIBUTE_DATA); UriAttribute linkedId = LinkedAttribute.fromAttributeData(data); loadIdentity(linkedId, certStatus); } catch (IOException e) { Log.e(Constants.TAG, "error parsing identity", e); Notify.create(getActivity(), "Error parsing identity!", Notify.LENGTH_LONG, Style.ERROR).show(); finishFragment(); } break; } }
From source file:org.totschnig.myexpenses.fragment.TemplatesList.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor c) { switch (loader.getId()) { case SORTABLE_CURSOR: mTemplatesCursor = c;/* www. ja v a 2 s . com*/ if (c != null && !indexesCalculated) { columnIndexRowId = c.getColumnIndex(KEY_ROWID); columnIndexAmount = c.getColumnIndex(KEY_AMOUNT); columnIndexLabelSub = c.getColumnIndex(KEY_LABEL_SUB); columnIndexComment = c.getColumnIndex(KEY_COMMENT); columnIndexPayee = c.getColumnIndex(KEY_PAYEE_NAME); columnIndexColor = c.getColumnIndex(KEY_COLOR); columnIndexTransferPeer = c.getColumnIndex(KEY_TRANSFER_PEER); columnIndexCurrency = c.getColumnIndex(KEY_CURRENCY); columnIndexTransferAccount = c.getColumnIndex(KEY_TRANSFER_ACCOUNT); columnIndexPlanId = c.getColumnIndex(KEY_PLANID); columnIndexTitle = c.getColumnIndex(KEY_TITLE); columnIndexPlanInfo = c.getColumnIndex(KEY_PLAN_INFO); indexesCalculated = true; } mAdapter.swapCursor(mTemplatesCursor); invalidateCAB(); if (isCalendarPermissionGranted() && mTemplatesCursor != null && mTemplatesCursor.moveToFirst()) { long needToExpand = expandedHandled ? ManageTemplates.NOT_CALLED : ((ManageTemplates) getActivity()).getCalledFromCalendarWithId(); boolean foundToExpand = false; while (!mTemplatesCursor.isAfterLast()) { long templateId = mTemplatesCursor.getLong(columnIndexRowId); if (needToExpand == templateId) { planMonthFragment = PlanMonthFragment.newInstance( mTemplatesCursor.getString(columnIndexTitle), templateId, mTemplatesCursor.getLong(columnIndexPlanId), mTemplatesCursor.getInt(columnIndexColor), false); foundToExpand = true; } mTemplatesCursor.moveToNext(); } if (needToExpand != ManageTemplates.NOT_CALLED) { expandedHandled = true; if (foundToExpand) { planMonthFragment.show(getChildFragmentManager(), CALDROID_DIALOG_FRAGMENT_TAG); } else { Toast.makeText(getActivity(), R.string.save_transaction_template_deleted, Toast.LENGTH_LONG) .show(); } } //look for plans that we could possible relink if (!repairTriggered && mTemplatesCursor.moveToFirst()) { final ArrayList<String> missingUuids = new ArrayList<>(); while (!mTemplatesCursor.isAfterLast()) { if (!mTemplatesCursor.isNull(columnIndexPlanId) && mTemplatesCursor.isNull(columnIndexPlanInfo)) { missingUuids.add(mTemplatesCursor.getString(mTemplatesCursor.getColumnIndex(KEY_UUID))); } mTemplatesCursor.moveToNext(); } if (missingUuids.size() > 0) { new RepairHandler(this) .obtainMessage(0, missingUuids.toArray(new String[missingUuids.size()])) .sendToTarget(); } } } break; } }
From source file:com.gvccracing.android.tttimer.Tabs.RaceInfoTab.java
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { try {//from w w w . j a v a 2s. co m Log.i(LOG_TAG(), "onLoadFinished start: id=" + Integer.toString(loader.getId())); switch (loader.getId()) { case RACE_INFO_LOADER: cursor.moveToFirst(); if (cursor.getCount() > 0) { Long raceDateMS = cursor.getLong(cursor.getColumnIndex(Race.RaceDate)); String courseName = cursor.getString(cursor.getColumnIndex(RaceLocation.CourseName)); long raceTypeID = cursor.getLong(cursor.getColumnIndex(Race.RaceType)); String raceTypeName = RaceType.DescriptionFromRaceTypeID(raceTypeID); String startIntervalText = Long .toString(cursor.getLong(cursor.getColumnIndex(Race.StartInterval))); long numRaceLaps = cursor.getLong(cursor.getColumnIndex(Race.NumLaps)); distance = Float.toString( cursor.getFloat(cursor.getColumnIndex(RaceLocation.Distance)) * (float) numRaceLaps); if (distance == null) { distance = ""; } if (raceTypeID == 1) { raceLaps.setText(Long.toString(numRaceLaps)); llRaceLaps.setVisibility(View.VISIBLE); } else { llRaceLaps.setVisibility(View.GONE); } Date raceDateTemp = new Date(raceDateMS); SimpleDateFormat formatter = new SimpleDateFormat("M/d/yy"); raceDate.setText(formatter.format(raceDateTemp).toString()); raceCourseName.setText(courseName); raceType.setText(raceTypeName); raceStartInterval.setText(startIntervalText); SetDistance(); } break; case APP_SETTINGS_LOADER_RACEINFO: getActivity().getSupportLoaderManager().restartLoader(COURSE_RECORD_LOADER, null, this); Integer distanceUnitID = Integer.parseInt(AppSettings.Instance().ReadValue(getActivity(), AppSettings.AppSetting_DistanceUnits_Name, "0")); distanceUnit = "mi"; switch (distanceUnitID) { case 0: distanceUnit = "mi"; break; case 1: distanceUnit = "km"; break; default: distanceUnit = "mi"; break; } getActivity().getSupportLoaderManager().restartLoader(RACE_INFO_LOADER, null, this); break; case COURSE_RECORD_LOADER: if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); long elapsedTime = cursor.getLong(cursor.getColumnIndex(RaceResults.ElapsedTime)); if (courseRecord != null) { courseRecord.setText(TimeFormatter.Format(elapsedTime, true, true, true, true, true, false, false, false)); } } break; } Log.i(LOG_TAG(), "onLoadFinished complete: id=" + Integer.toString(loader.getId())); } catch (Exception ex) { Log.e(LOG_TAG(), "onLoadFinished error", ex); } }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public void onLoaderReset(Loader<Cursor> loader) { switch (loader.getId()) { case LOADER_ID_SHIFT: break;/*from w ww . j ava 2 s .co m*/ case LOADER_ID_NAMES: mNameAdapter.swapCursor(null); break; } }
From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { switch (loader.getId()) { case LOADER_ID_LINKED_ID: // Nothing to load means break if we are *expected* to load if (!cursor.moveToFirst()) { if (mIdLoadedListener != null) { Notify.create(getActivity(), "Error loading identity!", Notify.LENGTH_LONG, Style.ERROR).show(); finishFragment();/* w ww . ja v a 2s. c o m*/ } // Or just ignore, this is probably some intermediate state during certify break; } try { int certStatus = cursor.getInt(UserIdsAdapter.INDEX_VERIFIED); byte[] data = cursor.getBlob(UserIdsAdapter.INDEX_ATTRIBUTE_DATA); UriAttribute linkedId = LinkedAttribute.fromAttributeData(data); loadIdentity(linkedId, certStatus); if (mIdLoadedListener != null) { mIdLoadedListener.onIdentityLoaded(); mIdLoadedListener = null; } } catch (IOException e) { Log.e(Constants.TAG, "error parsing identity", e); Notify.create(getActivity(), "Error parsing identity!", Notify.LENGTH_LONG, Style.ERROR).show(); finishFragment(); } break; } }
From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryDetail.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor c) { switch (loader.getId()) { case LOADER_ITINERARY: { if (c.moveToFirst()) { mItineraryCastCount = c.getInt(c.getColumnIndex(Itinerary._CASTS_COUNT)); final String description = c.getString(c.getColumnIndex(Itinerary._DESCRIPTION)); ((TextView) findViewById(R.id.description)).setText(description); ((TextView) findViewById(R.id.description_empty)).setText(description); ((TextView) findViewById(R.id.title)).setText(c.getString(c.getColumnIndex(Itinerary._TITLE))); if (USE_MAP) { final List<GeoPoint> path = Itinerary.getPath(c); mPathOverlay.setPath(path); mMapController.setCenter(mPathOverlay.getCenter()); if (Constants.USES_OSMDROID) { // this needs to be run after the MapView has been first sized due to a bug in zoomToSpan() mMapView.post(new Runnable() { @Override public void run() { if (mMapView.getHeight() > 0) { mMapController.zoomToSpan(mPathOverlay.getLatSpanE6(), mPathOverlay.getLonSpanE6()); } else { mMapView.post(this); }/*from w w w .j a va 2s . com*/ } }); } else { mMapController.zoomToSpan(mPathOverlay.getLatSpanE6(), mPathOverlay.getLonSpanE6()); } mMapView.setVisibility(View.VISIBLE); } } else { Log.e(TAG, "error loading itinerary"); } } 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:fr.shywim.antoinedaniel.ui.fragment.VideoDetailsFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { int id = loader.getId(); if (cursor.isClosed()) { Bundle args = new Bundle(); args.putString(ARG_VIDEO_ID, mVideoId); getLoaderManager().restartLoader(id, args, this); return;/*from w w w . j a v a2s. c om*/ } switch (id) { case MainActivity.LoaderID.VIDEO_DETAILS_SOUNDS: if (cursor.getCount() == 0) { ((View) mSoundsCat.getParent()).setVisibility(View.GONE); mSoundsSample.setVisibility(View.GONE); } else { ((View) mSoundsCat.getParent()).setVisibility(View.VISIBLE); mSoundsSample.setVisibility(View.VISIBLE); mSoundsCat.setText(cursor.getCount() + " Sons"); displayRandomSounds(mSoundsSample, cursor); } break; case MainActivity.LoaderID.VIDEO_DETAILS_MUSICS: if (cursor.getCount() == 0) { mMusicsCat.setVisibility(View.GONE); mMusicsList.setVisibility(View.GONE); } else { mMusicsCat.setVisibility(View.VISIBLE); mMusicsList.setVisibility(View.VISIBLE); mMusicsCat.setText(cursor.getCount() + " Musiques"); displayMusics(mMusicsList, cursor); } break; } cursor.close(); }
From source file:li.barter.fragments.ProfileFragment.java
@Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor cursor) { if (loader.getId() == Loaders.USER_DETAILS) { if (cursor.moveToFirst()) { mImageUrl = cursor.getString(cursor.getColumnIndex(DatabaseColumns.PROFILE_PICTURE)); final String firstName = cursor.getString(cursor.getColumnIndex(DatabaseColumns.FIRST_NAME)); final String lastName = cursor.getString(cursor.getColumnIndex(DatabaseColumns.LAST_NAME)); final String fullName = Utils.makeUserFullName(firstName, lastName); mOwnerNameTextView.setText(fullName); if (mLoadedIndividually && !TextUtils.isEmpty(fullName)) { setActionBarTitle(fullName); }/*from w w w . j av a2 s .c o m*/ mOwnerBarterLocationTextView.setText(String.format(mLocationFormat, cursor.getString(cursor.getColumnIndex(DatabaseColumns.NAME)), cursor.getString(cursor.getColumnIndex(DatabaseColumns.ADDRESS)))); //Set selected to do marquee if text length is very long mOwnerBarterLocationTextView.setSelected(true); if (!TextUtils.isEmpty(mImageUrl)) { Picasso.with(getActivity()).load(mImageUrl).transform(mAvatarBitmapTransformation) .error(R.drawable.pic_avatar).into(mOwnerImageView.getTarget()); } else { Picasso.with(getActivity()).load(R.drawable.pic_avatar).transform(mAvatarBitmapTransformation) .into(mOwnerImageView.getTarget()); } updateTab(mProfileFragmentsAdapter.getFragmentAtPosition(mViewPager.getCurrentItem())); } } }
From source file:org.sufficientlysecure.keychain.ui.EditKeyFragment.java
/** * 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. *///from w w w . ja va 2 s. c om public void onLoaderReset(Loader<Cursor> loader) { switch (loader.getId()) { case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(null); break; case LOADER_ID_SUBKEYS: mSubkeysAdapter.swapCursor(null); break; } }