List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.clevertrail.mobile.Database_SavedTrails.java
public String queueAll() { String[] columns = new String[] { "name", "json" }; Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null, null, null, null, null); String result = ""; int index_NAME = cursor.getColumnIndex("name"); for (cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()) { result = result + cursor.getString(index_NAME) + "\n"; }/*from www .j av a 2s . co m*/ return result; }
From source file:gov.wa.wsdot.android.wsdot.ui.HighImpactAlertsFragment.java
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { alertItems.clear();/* w w w. ja v a 2 s .co m*/ if (cursor.moveToFirst()) { while (!cursor.isAfterLast()) { HighwayAlertsItem item = new HighwayAlertsItem(); item.setAlertId(cursor.getString(0)); item.setStartLatitude(cursor.getDouble(1)); item.setStartLongitude(cursor.getDouble(2)); item.setEventCategory(cursor.getString(3)); item.setExtendedDescription(cursor.getString(4)); item.setLastUpdatedTime(cursor.getString(6)); alertItems.add(item); cursor.moveToNext(); } } else { HighwayAlertsItem item = new HighwayAlertsItem(); item.setEventCategory("empty"); alertItems.add(item); } mLoadingSpinner.setVisibility(View.GONE); mPager.setVisibility(View.VISIBLE); mIndicator.setVisibility(View.VISIBLE); mAdapter = new ViewPagerAdapter(getActivity(), alertItems); mPager.setAdapter(mAdapter); mIndicator.setViewPager(mPager); }
From source file:de.elanev.studip.android.app.frontend.courses.CoursesFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (getActivity() == null) { return;/*from ww w. j av a 2 s .c o m*/ } cursor.moveToFirst(); if (!cursor.isAfterLast()) { ArrayList<SectionedCursorAdapter.Section> sections = new ArrayList<SectionedCursorAdapter.Section>(); String prevSemesterId = ""; String currSemesterId = ""; int semesterIdIdx = cursor.getColumnIndex(SEMESTER_ID); int semesterTitleIdx = cursor.getColumnIndex(SEMESTER_TITLE); while (!cursor.isAfterLast()) { currSemesterId = cursor.getString(semesterIdIdx); if (!TextUtils.equals(prevSemesterId, currSemesterId)) { sections.add(new SectionedCursorAdapter.Section(cursor.getPosition(), cursor.getString(semesterTitleIdx))); } prevSemesterId = currSemesterId; cursor.moveToNext(); } mAdapter.setSections(sections); } mAdapter.swapCursor(cursor); mSwipeRefreshLayoutListView.setRefreshing(false); }
From source file:org.smap.smapTask.android.loaders.TaskLoader.java
private void getForms(ArrayList<TaskEntry> entries) { String[] proj = { FormsColumns._ID, FormsColumns.JR_FORM_ID, FormsColumns.JR_VERSION, FormsColumns.PROJECT, FormsColumns.DISPLAY_NAME }; String sortOrder = FormsColumns.DISPLAY_NAME + " ASC, " + FormsColumns.JR_VERSION + " DESC"; String selectClause = FormsColumns.SOURCE + "='" + Utilities.getSource() + "' or " + FormsColumns.SOURCE + " is null"; final ContentResolver resolver = Collect.getInstance().getContentResolver(); Cursor formListCursor = resolver.query(FormsColumns.CONTENT_URI, proj, selectClause, null, sortOrder); if (formListCursor != null) { formListCursor.moveToFirst();//from w ww . ja v a 2 s .c o m while (!formListCursor.isAfterLast()) { TaskEntry entry = new TaskEntry(); entry.type = "form"; entry.ident = formListCursor.getString(formListCursor.getColumnIndex(FormsColumns.JR_FORM_ID)); entry.formVersion = formListCursor.getInt(formListCursor.getColumnIndex(FormsColumns.JR_VERSION)); entry.name = formListCursor.getString(formListCursor.getColumnIndex(FormsColumns.DISPLAY_NAME)); entry.project = formListCursor.getString(formListCursor.getColumnIndex(FormsColumns.PROJECT)); entry.id = formListCursor.getLong(formListCursor.getColumnIndex(FormsColumns._ID)); entries.add(entry); formListCursor.moveToNext(); } } if (formListCursor != null) { formListCursor.close(); } }
From source file:com.doctoror.fuckoffmusicplayer.presentation.media.browser.MediaBrowserImpl.java
@Nullable private List<MediaItem> mediaItemsFromGenresCursor(@Nullable final Cursor c) { List<MediaItem> mediaItems = null; if (c != null) { mediaItems = new ArrayList<>(c.getCount()); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { mediaItems.add(createMediaItemGenre(c)); }//from w ww . j a v a 2 s. c om c.close(); } return mediaItems; }
From source file:com.doctoror.fuckoffmusicplayer.presentation.media.browser.MediaBrowserImpl.java
@Nullable private List<MediaItem> recentAlbumsFromCursor(@Nullable final Cursor c) { List<MediaItem> mediaItems = null; if (c != null) { mediaItems = new ArrayList<>(c.getCount()); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { mediaItems.add(createMediaItemAlbum(c)); }/*from www . j a v a2s .com*/ c.close(); } return mediaItems; }
From source file:edu.pdx.cecs.orcycle.Uploader.java
private boolean SendAllSegments() { boolean result = true; Vector<Long> unsentSegmentIds = new Vector<Long>(); mDb.openReadOnly();// w w w . j a v a2s . c o m try { Cursor cursor = mDb.fetchUnsentSegmentIds(); try { if (cursor != null && cursor.getCount() > 0) { // pd.setMessage("Sent. You have previously unsent notes; submitting those now."); while (!cursor.isAfterLast()) { unsentSegmentIds.add(Long.valueOf(cursor.getLong(0))); cursor.moveToNext(); } } } finally { cursor.close(); } } finally { mDb.close(); } for (Long segmentId : unsentSegmentIds) { result &= uploadOneSegment(segmentId); } return result; }
From source file:net.potterpcs.recipebook.DirectionsEditor.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = (RecipeEditor) getActivity(); long rid = activity.getRecipeId(); directions = new ArrayList<String>(); photoUris = new ArrayList<String>(); currentDirection = -1;//from w ww. java 2 s . c om currentPhoto = null; if (savedInstanceState != null) { // Load from the saved state if possible String[] savedDirections = savedInstanceState.getStringArray(STATE_DIRS); String[] savedUris = savedInstanceState.getStringArray(STATE_PHOTOS); if (savedDirections != null) { directions.addAll(Arrays.asList(savedDirections)); } if (savedUris != null) { photoUris.addAll(Arrays.asList(savedUris)); } } else { // There's no saved state, so we can load a recipe from the database // if needed, or start a new one. if (rid > 0) { // Load an existing recipe for editing RecipeBook app = (RecipeBook) activity.getApplication(); Cursor c = app.getData().getRecipeDirections(rid); c.moveToFirst(); while (!c.isAfterLast()) { String value = c.getString(c.getColumnIndex(RecipeData.DT_STEP)); directions.add(value); String photo = c.getString(c.getColumnIndex(RecipeData.DT_PHOTO)); photoUris.add(photo); c.moveToNext(); } c.close(); } else { // Start a new recipe (this requires no extra setup) } } adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, directions); return inflater.inflate(R.layout.directionsedit, container, false); }
From source file:com.clevertrail.mobile.Database_SavedTrails.java
public String getJSONString(String sName) { String[] columns = new String[] { "json" }; String selection = "name = '" + sName + "'"; Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, selection, null, null, null, null); cursor.moveToFirst();//from w ww . j a va2s . c om int index_JSON = cursor.getColumnIndex("json"); String sReturn = ""; if (!cursor.isAfterLast()) sReturn = cursor.getString(index_JSON); return sReturn; }
From source file:com.dustinmreed.openwifi.MapActivityFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { List<Marker> markers = new ArrayList<>(); if (data != null && data.moveToFirst()) { data.moveToFirst();/*from w ww .j a v a2 s. c o m*/ while (!data.isAfterLast()) { siteName = data.getString(COL_WIFILOCATION_NAME); String siteType = data.getString(COL_WIFILOCATION_TYPE); final String siteAddress = data.getString(COL_WIFILOCATION_ADDRESS); final String siteCity = data.getString(COL_WIFILOCATION_CITY); String siteState = data.getString(COL_WIFILOCATION_STATE); String siteZipcode = data.getString(COL_WIFILOCATION_ZIPCODE); Double latitude = Double.valueOf(data.getString(COL_WIFILOCATION_LAT)); Double longitude = Double.valueOf(data.getString(COL_WIFILOCATION_LONG)); // Gets to GoogleMap from the MapView and does initialization stuff map = mapView.getMap(); map.getUiSettings().setMyLocationButtonEnabled(false); Marker newmarker; LatLng latlng = new LatLng(latitude, longitude); switch (siteType) { case "Library": newmarker = map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); break; case "Regional Community Center": newmarker = map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE))); break; default: newmarker = map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); break; } markers.add(newmarker); data.moveToNext(); } LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Marker marker : markers) { builder.include(marker.getPosition()); } LatLngBounds bounds = builder.build(); int padding = 100; // offset from edges of the map in pixels cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); try { map.moveCamera(cu); map.animateCamera(cu); } catch (IllegalStateException ise) { map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { map.moveCamera(cu); map.animateCamera(cu); } }); } } }