List of usage examples for android.database Cursor isClosed
boolean isClosed();
From source file:org.gnucash.android.db.DatabaseCursorLoader.java
@Override public void deliverResult(Cursor data) { if (isReset()) { if (data != null) { onReleaseResources(data);// w w w . j a v a 2 s .c om } return; } Cursor oldCursor = mCursor; mCursor = data; if (isStarted()) { super.deliverResult(data); } if (oldCursor != null && oldCursor != data && !oldCursor.isClosed()) { onReleaseResources(oldCursor); } }
From source file:org.mariotaku.twidere.activity.support.DraftsActivity.java
@Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case MENU_DELETE: { // TODO confim dialog and image removal final Where where = Where.in(new Column(Drafts._ID), new RawItemArray(mListView.getCheckedItemIds())); mResolver.delete(Drafts.CONTENT_URI, where.getSQL(), null); break;//from w w w . j a v a 2s . c o m } case MENU_SEND: { final Cursor c = mAdapter.getCursor(); if (c == null || c.isClosed()) return false; final SparseBooleanArray checked = mListView.getCheckedItemPositions(); final List<DraftItem> list = new ArrayList<DraftItem>(); final DraftItem.CursorIndices indices = new DraftItem.CursorIndices(c); for (int i = 0, j = checked.size(); i < j; i++) { if (checked.valueAt(i) && c.moveToPosition(checked.keyAt(i))) { list.add(new DraftItem(c, indices)); } } if (sendDrafts(list)) { final Where where = Where.in(new Column(Drafts._ID), new RawItemArray(mListView.getCheckedItemIds())); mResolver.delete(Drafts.CONTENT_URI, where.getSQL(), null); } break; } default: { return false; } } mode.finish(); return true; }
From source file:org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.java
@Override public KeyItem getItem(int position) { Cursor c = getCursor(); if (c.isClosed() || !c.moveToPosition(position)) { return null; }//from www .j ava2s.c o m return new KeyItem(c); }
From source file:com.commonsware.cwac.loaderex.AbstractCursorLoader.java
/** * Runs on the UI thread, routing the results from the * background thread to whatever is using the Cursor * (e.g., a CursorAdapter)./*from ww w . j a v a 2s .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; } Cursor oldCursor = lastCursor; lastCursor = cursor; if (isStarted()) { super.deliverResult(cursor); } if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:com.aboveware.sms.ui.MessageListAdapter.java
private boolean isCursorValid(Cursor cursor) { // Check whether the cursor is valid or not. if (cursor == null || cursor.isClosed() || cursor.isBeforeFirst() || cursor.isAfterLast()) { return false; }//w w w . j av a 2 s . c o m return true; }
From source file:com.vasilkoff.android.UI.VideosListFragment.java
/** * Load an article in the default browser when selected by the user. *//* w ww.ja v a 2 s .com*/ @Override public void onListItemClick(ListView listView, View view, int position, long id) { super.onListItemClick(listView, view, position, id); Cursor c = (Cursor) mAdapter.getItem(position); if (!c.isClosed()) { final int colId = c.getColumnIndex("id"); String t = c.getString(colId); if (t == null) { Log.e(TAG, "Attempt to launch entry with null link"); return; } new AlertDialog.Builder(getContext()).setTitle("Selected").setMessage(t) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // I <3 Android :) } }).show(); } }
From source file:com.michaelrnovak.objectcursor.ObjectCursorLoader.java
@Override public void deliverResult(ObjectCursor<T> cursor) { if (isReset()) { if (cursor != null) { cursor.close();//from ww w. j a v a 2s . c o m } return; } final Cursor oldCursor = mCursor; mCursor = cursor; if (isStarted()) { super.deliverResult(cursor); } if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:li.barter.data.SQLiteLoader.java
@Override public void deliverResult(final Cursor data) { if (isReset()) { if (data != null) { data.close();//from w w w. j av a2 s . co m } return; } final Cursor oldCursor = mCursor; mCursor = data; if (isStarted()) { super.deliverResult(data); } if ((oldCursor != null) && (oldCursor != data) && !oldCursor.isClosed()) { oldCursor.close(); } }
From source file:com.hplasplas.weather.activitys.SearchPlaceActivity.java
@Override public void onNewPlaceCursorReady(MainContract.SearchCursor cursor, MainContract.SearchCustomer whoAsked) { if (DEBUG) {/*from w ww. j a va 2 s. c o m*/ Log.d(TAG, "onCursorReady: "); } if (whoAsked == this) { if (mSearchMenuItem == null || !mSearchMenuItem.isActionViewExpanded()) { cursor.close(); } else { Cursor oldCursor = mSearchView.getSuggestionsAdapter().swapCursor(cursor); if (oldCursor != null && !oldCursor.isClosed()) { oldCursor.close(); } if (clearTextIfNoResult && (cursor == null || !cursor.moveToFirst())) { mSearchView.setQuery(null, false); mSearchView.setQueryHint(getResources().getString(R.string.no_result)); } setProgressBarState(mSearchProgressBar, false); } } }
From source file:fr.shywim.antoinedaniel.ui.fragment.VideoListFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor.isClosed()) { Activity activity = getActivity(); if (activity != null) { getLoaderManager().restartLoader(MainActivity.VIDEOS, null, this); }/* w w w . ja va2 s . co m*/ return; } Cursor oldCursor = ((CursorRecyclerAdapter) listView.getAdapter()).swapCursor(cursor); if (oldCursor != null && !oldCursor.isClosed()) oldCursor.close(); }