List of usage examples for android.database Cursor isClosed
boolean isClosed();
From source file:br.com.estudio89.rv_tools.SimpleCursorLoader.java
@Override public void deliverResult(Cursor cursor) { if (isReset()) { // An async query came in while the loader is stopped if (cursor != null) { cursor.close();//from ww w .jav a2 s . co m } return; } Cursor oldCursor = mCursor; mCursor = cursor; if (isStarted()) { super.deliverResult(cursor); } if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:com.gelakinetic.mtgfam.helpers.AutocompleteCursorAdapter.java
/** * Called when a previously created loader has finished its load. * * @param loader The Loader that has finished. * @param data The data generated by the Loader. *///from ww w . jav a2 s . c om @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { try { Cursor old; if (data != null && data.isClosed()) { old = this.swapCursor(null); } else { old = this.swapCursor(data); } if (old != null) { old.close(); } } catch (NullPointerException e) { /* eat it */ } }
From source file:com.hplasplas.weather.activitys.SearchPlaceActivity.java
private void closeCursor(SearchView searchView) { if (searchView != null) { CursorAdapter adapter = searchView.getSuggestionsAdapter(); if (adapter != null) { Cursor cursor = adapter.swapCursor(null); if (cursor != null && !cursor.isClosed()) { cursor.close();/* w ww. j av a 2s . c o m*/ } } } }
From source file:at.flack.MainActivity.java
public static String getContactName(Context context, String phoneNumber) { if (phoneNumber == null || phoneNumber.length() == 0) return phoneNumber; ContentResolver cr = context.getContentResolver(); Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); Cursor cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null); if (cursor == null) { return null; }/*www . j a va 2 s .c o m*/ String contactName = null; if (cursor.moveToFirst()) { contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME)); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return contactName; }
From source file:org.mozilla.gecko.home.SimpleCursorLoader.java
@Override public void deliverResult(Cursor cursor) { if (isReset()) { // An async query came in while the loader is stopped if (cursor != null) { cursor.close();/* w w w . ja va2 s .com*/ } return; } Cursor oldCursor = mCursor; mCursor = cursor; if (isStarted()) { super.deliverResult(cursor); } if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:co.nerdart.ourss.fragment.EntriesListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_share_starred: { String starredList = ""; Cursor cursor = mEntriesCursorAdapter.getCursor(); if (cursor != null && !cursor.isClosed()) { int titlePos = cursor.getColumnIndex(EntryColumns.TITLE); int linkPos = cursor.getColumnIndex(EntryColumns.LINK); if (cursor.moveToFirst()) { do { starredList += cursor.getString(titlePos) + "\n" + cursor.getString(linkPos) + "\n\n"; } while (cursor.moveToNext()); }// w w w .j a v a2 s .co m startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND) .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_favorites_title)) .putExtra(Intent.EXTRA_TEXT, starredList).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } return true; } case R.id.menu_refresh: { if (!FetcherService.isRefreshingFeeds) { getActivity().startService( new Intent(getActivity(), FetcherService.class).setAction(Constants.ACTION_REFRESH_FEEDS)); } return true; } case R.id.menu_all_read: { mEntriesCursorAdapter.markAllAsRead(); return true; } case R.id.menu_hide_read: { if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) { PrefUtils.putBoolean(PrefUtils.SHOW_READ, true); item.setTitle(R.string.context_menu_hide_read).setIcon(R.drawable.hide_reads); } else { PrefUtils.putBoolean(PrefUtils.SHOW_READ, false); item.setTitle(R.string.context_menu_show_read).setIcon(R.drawable.view_reads); } return true; } case R.id.menu_settings: { startActivity(new Intent(getActivity(), GeneralPrefsActivity.class)); return true; } } return super.onOptionsItemSelected(item); }
From source file:de.aw.awlib.views.AWAutoCompleteTextView.java
@Override protected void onDetachedFromWindow() { SimpleCursorAdapter adapter = (SimpleCursorAdapter) getAdapter(); if (adapter != null) { Cursor c = adapter.swapCursor(null); if (c != null && !c.isClosed()) { c.close();// w ww . j a va 2 s . com } } super.onDetachedFromWindow(); }
From source file:uk.org.rivernile.android.utils.SimpleCursorLoader.java
/** * {@inheritDoc}//from w w w . j a va2s. co m */ @Override public void deliverResult(Cursor cursor) { if (isReset()) { // An async query came in while the loader is stopped if (cursor != null) { cursor.close(); } return; } final Cursor oldCursor = mCursor; mCursor = cursor; if (isStarted()) { super.deliverResult(cursor); } if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:de.vanita5.twittnuker.adapter.UserHashtagAutoCompleteAdapter.java
public void closeCursor() { final Cursor cursor = getCursor(); if (cursor == null) return;/*w w w . j av a2 s . com*/ if (!cursor.isClosed()) { cursor.close(); } }
From source file:com.conferenceengineer.android.iosched.ui.TracksAdapter.java
private void updateSpecialItemPositions(Cursor cursor) { mFirstLevel2CursorPosition = -1;/*w w w. j av a2 s.c o m*/ if (cursor != null && !cursor.isClosed()) { cursor.moveToFirst(); while (cursor.moveToNext()) { if (cursor.getInt(TracksQuery.TRACK_LEVEL) == 2) { mFirstLevel2CursorPosition = cursor.getPosition(); break; } } } }