List of usage examples for android.support.v4.os OperationCanceledException OperationCanceledException
public OperationCanceledException()
From source file:eu.geopaparazzi.library.database.RawSqlCursorLoader.java
@Override public Cursor loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); }/*ww w .j a va2 s. co m*/ mCancellationSignal = new CancellationSignal(); } try { Cursor cursor = mDatabase.rawQuery(mSql, null); if (cursor != null) { try { // Ensure the cursor window is filled. cursor.getCount(); cursor.registerContentObserver(mObserver); } catch (RuntimeException ex) { cursor.close(); throw ex; } } return cursor; } finally { synchronized (this) { mCancellationSignal = null; } } }
From source file:cn.tangxb.imageselector.PhotoModelTaskLoader.java
@Override public ArrayList<PhotoModel> loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); }/*from www . java2s .c o m*/ mCancellationSignal = new CancellationSignal(); } try { Cursor cursor = ContentResolverCompat.query(getContext().getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.DATE_ADDED, MediaStore.Images.ImageColumns.SIZE }, null, null, MediaStore.Images.ImageColumns.DATE_ADDED, mCancellationSignal); if (cursor != null) { try { // Ensure the cursor window is filled. cursor.getCount(); cursor.registerContentObserver(mObserver); mData = new ArrayList<>(); if (cursor == null || !cursor.moveToNext()) return mData; cursor.moveToLast(); do { if (cursor.getLong(cursor.getColumnIndex(MediaStore.Images.ImageColumns.SIZE)) > 1024 * 10) { PhotoModel photoModel = new PhotoModel(); photoModel.setOriginalPath( cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA))); mData.add(photoModel); } } while (cursor.moveToPrevious()); } catch (RuntimeException ex) { cursor.close(); throw ex; } } return mData; } finally { synchronized (this) { mCancellationSignal = null; } } }
From source file:io.requery.android.database.sqlite.SQLiteConnectionPool.java
private void cancelConnectionWaiterLocked(ConnectionWaiter waiter) { if (waiter.mAssignedConnection != null || waiter.mException != null) { // Waiter is done waiting but has not woken up yet. return;/* w w w. j av a2 s. com*/ } // Waiter must still be waiting. Dequeue it. ConnectionWaiter predecessor = null; ConnectionWaiter current = mConnectionWaiterQueue; while (current != waiter) { assert current != null; predecessor = current; current = current.mNext; } if (predecessor != null) { predecessor.mNext = waiter.mNext; } else { mConnectionWaiterQueue = waiter.mNext; } // Send the waiter an exception and unpark it. waiter.mException = new OperationCanceledException(); LockSupport.unpark(waiter.mThread); // Check whether removing this waiter will enable other waiters to make progress. wakeConnectionWaitersLocked(); }