微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.os.OperationCanceledException的实例源码

项目:easyfilemanager    文件DirectoryFragment.java   
@Override
protected Long doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    Long result = null;
    try {
        if (!TextUtils.isEmpty(mPath)) {
            File dir = new File(mPath);
            result = Utils.getDirectorySize(dir);
        }
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG,"Failed to calculate size for " + mPath + ": " + e);
        }
        CrashReportingManager.logException(e);
    }
    return result;
}
项目:easyfilemanager    文件UriDerivativeLoader.java   
@Override
public final R loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled2()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    try {
        return loadInBackground(mParam,mCancellationSignal);
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
}
项目:easyfilemanager    文件DocumentsContract.java   
/**
 * Return thumbnail representing the document at the given URI. Callers are
 * responsible for their own in-memory caching.
 *
 * @param documentUri document to return thumbnail for,which must have
 *            {@link Document#FLAG_SUPPORTS_THUMBNAIL} set.
 * @param size optimal thumbnail size desired. A provider may return a
 *            thumbnail of a different size,but never more than double the
 *            requested size.
 * @param signal signal used to indicate if caller is no longer interested
 *            in the thumbnail.
 * @return decoded thumbnail,or {@code null} if problem was encountered.
 * @see DocumentsProvider#opendocumentThumbnail(String,Point,*      CancellationSignal)
 */
public static Bitmap getDocumentThumbnail(
        ContentResolver resolver,Uri documentUri,Point size,CancellationSignal signal) {
    final ContentProviderClient client = ContentProviderClientCompat.acquireUnstableContentProviderClient(resolver,documentUri.getAuthority());
    try {
        if(UsbStorageProvider.AUTHORITY.equals(documentUri.getAuthority())) {
            return ImageUtils.getThumbnail(resolver,documentUri,size.x,size.y);
        }
        return getDocumentThumbnails(client,size,signal);
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG,"Failed to load thumbnail for " + documentUri + ": " + e);
        }
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
项目:easyfilemanager    文件AsyncTaskLoader.java   
@Override
protected D doInBackground(Void... params) {
    if (DEBUG) Log.v(TAG,this + " >>> doInBackground");
    try {
        D data = AsyncTaskLoader.this.onLoadInBackground();
        if (DEBUG) Log.v(TAG,this + "  <<< doInBackground");
        return data;
    } catch (OperationCanceledException ex) {
        if (!isCancelled()) {
            // onLoadInBackground threw a canceled exception spurIoUsly.
            // This is problematic because it means that the LoaderManager did not
            // cancel the Loader itself and still expects to receive a result.
            // Additionally,the Loader's own state will not have been updated to
            // reflect the fact that the task was being canceled.
            // So we treat this case as an unhandled exception.
            throw ex;
        }
        if (DEBUG) Log.v(TAG,this + "  <<< doInBackground (was canceled)",ex);
        return null;
    }
}
项目:YuiHatano    文件ShadowDatabaseUtils.java   
private static final void readExceptionFromParcel(Parcel reply,String msg,int code) {
    switch (code) {
        case 2:
            throw new IllegalArgumentException(msg);
        case 3:
            throw new UnsupportedOperationException(msg);
        case 4:
            throw new sqliteAbortException(msg);
        case 5:
            throw new sqliteConstraintException(msg);
        case 6:
            throw new sqliteDatabaseCorruptException(msg);
        case 7:
            throw new sqliteFullException(msg);
        case 8:
            throw new sqlitediskIOException(msg);
        case 9:
            throw new sqliteException(msg);
        case 11:
            throw new OperationCanceledException(msg);
        default:
            reply.readException(code,msg);
    }
}
项目:FireFiles    文件DirectoryFragment.java   
@Override
protected Long doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    Long result = null;
    try {
        if (!TextUtils.isEmpty(mPath)) {
            File dir = new File(mPath);
            result = Utils.getDirectorySize(dir);
        }
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG,"Failed to calculate size for " + mPath + ": " + e);
        }
        CrashReportingManager.logException(e);
    }
    return result;
}
项目:FireFiles    文件UriDerivativeLoader.java   
@Override
public final R loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled2()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    try {
        return loadInBackground(mParam,mCancellationSignal);
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
}
项目:FireFiles    文件DocumentsContract.java   
/**
 * Return thumbnail representing the document at the given URI. Callers are
 * responsible for their own in-memory caching.
 *
 * @param documentUri document to return thumbnail for,"Failed to load thumbnail for " + documentUri + ": " + e);
        }
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
项目:FireFiles    文件AsyncTaskLoader.java   
@Override
protected D doInBackground(Void... params) {
    if (DEBUG) Log.v(TAG,ex);
        return null;
    }
}
项目:simple-share-android    文件DirectoryFragment.java   
@Override
protected Long doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    Long result = null;
    try {
        if (!TextUtils.isEmpty(mPath)) {
            File dir = new File(mPath);
            result = Utils.getDirectorySize(dir);
        }
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG,"Failed to calculate size for " + mPath + ": " + e);
        }
        CrashReportingManager.logException(e);
    }
    return result;
}
项目:simple-share-android    文件UriDerivativeLoader.java   
@Override
public final R loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled2()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    try {
        return loadInBackground(mParam,mCancellationSignal);
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
}
项目:simple-share-android    文件DocumentsContract.java   
/**
 * Return thumbnail representing the document at the given URI. Callers are
 * responsible for their own in-memory caching.
 *
 * @param documentUri document to return thumbnail for,"Failed to load thumbnail for " + documentUri + ": " + e);
        }
        return null;
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
}
项目:simple-share-android    文件AsyncTaskLoader.java   
@Override
protected D doInBackground(Void... params) {
    if (DEBUG) Log.v(TAG,ex);
        return null;
    }
}
项目:KBUnitTest    文件ShadowDatabaseUtils.java   
private static final void readExceptionFromParcel(Parcel reply,msg);
    }
}
项目:forsuredbandroid    文件FSCursorLoader.java   
@Override
public FSCursor loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }

    FSCursor cursor = (FSCursor) resolver.preserveQueryStateAndGet();
    if (cursor != null) {
        try {
            cursor.getCount();  // Todo: determine whether you need to make this call
        } catch (RuntimeException ex) {
            cursor.close();
            throw ex;
        }
    }
    return cursor;
}
项目:FullRobolectricTestSample    文件sqliteDatabaseTest.java   
@Test
public void testRawQueryWithFactoryAndCancellationSignal() throws Exception {
    CancellationSignal signal = new CancellationSignal();

    Cursor cursor = database.rawQueryWithFactory(null,"select * from table_name",null,signal);
    assertthat(cursor).isNotNull();
    assertthat(cursor.getColumnCount()).isEqualTo(5);
    assertthat(cursor.isClosed()).isFalse();

    signal.cancel();

    try {
        cursor.movetoNext();
        fail("did not get cancellation signal");
    } catch (OperationCanceledException e) {
        // expected
    }
}
项目:easyfilemanager    文件DetailFragment.java   
@Override
protected Void doInBackground(Void... params) {
    filePath = doc.path;

    if (!Utils.isDir(doc.mimeType)) {
              final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES,doc.mimeType);
        int thumbSize = getResources().getDimensionPixelSize(R.dimen.grid_width);
        Point mThumbSize = new Point(thumbSize,thumbSize);
        final Uri uri = DocumentsContract.buildDocumentUri(doc.authority,doc.documentId);
        final Context context = getActivity();
        final ContentResolver resolver = context.getContentResolver();
        ContentProviderClient client = null;
        try {

            if (doc.mimeType.equals(Document.MIME_TYPE_APK) && !TextUtils.isEmpty(filePath)) {
                result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context,filePath,Document.MIME_TYPE_APK)).getBitmap();
            } else {
                client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver,uri.getAuthority());
                result = DocumentsContract.getDocumentThumbnail(resolver,uri,mThumbSize,null);
            }
        } catch (Exception e) {
            if (!(e instanceof OperationCanceledException)) {
                Log.w(TAG_DETAIL,"Failed to load thumbnail for " + uri + ": " + e);
            }
            CrashReportingManager.logException(e);
        } finally {
            ContentProviderClientCompat.releaseQuietly(client);
        }

        sizeString = Formatter.formatFileSize(context,doc.size);
    }
    else{
        if(!TextUtils.isEmpty(filePath)){
            File dir = new File(filePath);
            sizeString = Formatter.formatFileSize(getActivity(),Utils.getDirectorySize(dir));
        }               
    }

    return null;
}
项目:easyfilemanager    文件DirectoryFragment.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        if (Utils.isAPK(mMimeType)) {
            result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context,mPath,Document.MIME_TYPE_APK)).getBitmap();
        } else {
            client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver,mUri.getAuthority());
            result = DocumentsContract.getDocumentThumbnail(resolver,mUri,mSignal);
        }
        if (null == result){
            result = ImageUtils.getThumbnail(mPath,mMimeType,mThumbSize.x,mThumbSize.y);
        }
        if (result != null) {
            final ThumbnailCache thumbs = DocumentsApplication.getThumbnailsCache(context,mThumbSize);
            thumbs.put(mUri,result);
        }
    } catch (Exception e) {
        if (!(e instanceof OperationCanceledException)) {
            Log.w(TAG,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:easyfilemanager    文件IconHelper.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver,mUri.getAuthority());
        result = DocumentsContract.getDocumentThumbnail(resolver,mSignal);

        if (null == result){
            result = ImageUtils.getThumbnail(mPath,mimeType,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:YuiHatano    文件ShadowDatabaseUtils.java   
/**
 * Special function for writing an exception result at the header of
 * a parcel,to be used when returning an exception from a transaction.
 * exception will be re-thrown by the function in another process
 *
 * @param reply Parcel to write to
 * @param e     The Exception to be written.
 * @see Parcel#writeNoException
 * @see Parcel#writeException
 */
public static final void writeExceptionToParcel(Parcel reply,Exception e) {
    int     code         = 0;
    boolean logException = true;
    if (e instanceof FileNotFoundException) {
        code = 1;
        logException = false;
    } else if (e instanceof IllegalArgumentException) {
        code = 2;
    } else if (e instanceof UnsupportedOperationException) {
        code = 3;
    } else if (e instanceof sqliteAbortException) {
        code = 4;
    } else if (e instanceof sqliteConstraintException) {
        code = 5;
    } else if (e instanceof sqliteDatabaseCorruptException) {
        code = 6;
    } else if (e instanceof sqliteFullException) {
        code = 7;
    } else if (e instanceof sqlitediskIOException) {
        code = 8;
    } else if (e instanceof sqliteException) {
        code = 9;
    } else if (e instanceof OperationApplicationException) {
        code = 10;
    } else if (e instanceof OperationCanceledException) {
        code = 11;
        logException = false;
    } else {
        reply.writeException(e);
        Log.e(TAG,"Writing exception to parcel",e);
        return;
    }
    reply.writeInt(code);
    reply.writeString(e.getMessage());

    if (logException) {
        Log.e(TAG,e);
    }
}
项目:FireFiles    文件DetailFragment.java   
@Override
protected Void doInBackground(Void... params) {
    filePath = doc.path;

    if (!Utils.isDir(doc.mimeType)) {
              final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES,Utils.getDirectorySize(dir));
        }               
    }

    return null;
}
项目:FireFiles    文件DirectoryFragment.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        if (Utils.isAPK(mMimeType)) {
            result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:FireFiles    文件IconHelper.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:simple-share-android    文件DetailFragment.java   
@Override
protected Void doInBackground(Void... params) {
    filePath = doc.path;

    if (!Utils.isDir(doc.mimeType)) {
              final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES,Utils.getDirectorySize(dir));
        }               
    }

    return null;
}
项目:simple-share-android    文件DirectoryFragment.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        if (Utils.isAPK(mMimeType)) {
            result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:simple-share-android    文件IconHelper.java   
@Override
protected Bitmap doInBackground(Uri... params) {
    if (isCancelled())
        return null;

    final Context context = mIconThumb.getContext();
    final ContentResolver resolver = context.getContentResolver();

    ContentProviderClient client = null;
    Bitmap result = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver,"Failed to load thumbnail for " + mUri + ": " + e);
        }
        CrashReportingManager.logException(e);
    } finally {
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return result;
}
项目:KBUnitTest    文件ShadowDatabaseUtils.java   
/**
 * Special function for writing an exception result at the header of
 * a parcel,e);
    }
}
项目:android_database    文件BaseCursorDataLoader.java   
/**
 */
@Override
public D loadInBackground() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        synchronized (this) {
            if (isLoadInBackgroundCanceled()) {
                throw new OperationCanceledException();
            }
            this.mCancellationSignal = new CancellationSignal();
        }
    }
    try {
        final Cursor cursor = query();
        if (cursor != null) {
            try {
                // Ensure that the cursor window is filled.
                cursor.getCount();
                cursor.registerContentObserver(mObserver);
            } catch (RuntimeException e) {
                cursor.close();
                throw e;
            }
        }
        return cursor == null ? onLoadFailed() : onLoadFinished(cursor);
    } finally {
        synchronized (this) {
            this.mCancellationSignal = null;
        }
    }
}
项目:sprockets-android    文件CursorWrapperLoader.java   
@Override
public D loadInBackground() {
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        mCancellationSignal = new CancellationSignal();
    }
    try {
        Cursor cursor = getContext().getContentResolver()
                .query(mUri,mProjection,mSelection,mSelectionArgs,mSortOrder,mCancellationSignal);
        if (cursor != null) {
            try {
                // Ensure the cursor window is filled.
                cursor.getCount();
                cursor.registerContentObserver(mObserver);
            } catch (RuntimeException ex) {
                cursor.close();
                throw ex;
            }
            return wrap(cursor);
        }
        return null;
    } finally {
        synchronized (this) {
            mCancellationSignal = null;
        }
    }
}
项目:android-oauth-client    文件OAuthManagerTest.java   
@Test(expected = RuntimeException.class)
public void testTaskExecutionThatThrowsException() throws OperationCanceledException,IOException {
    OAuthFuture<String> future = mock.runTest(new Runnable() {
        @Override
        public void run() {
            throw new RuntimeException();
        }
    },null);
    future.getResult();
}
项目:android-oauth-client    文件OAuthManagerTest.java   
@Test
public void testCallback() throws InterruptedException,OperationCanceledException,IOException {
    MockOAuthCallback mockCallback = new MockOAuthCallback();
    mock.runTest(null,mockCallback,null);
    latch.await(10,TimeUnit.SECONDS);
    assertEquals("ok",mockCallback.getResult());
}
项目:boohee_v5.6    文件ContentResolverCompatJellybean.java   
static boolean isFrameworkOperationCanceledException(Exception e) {
    return e instanceof OperationCanceledException;
}
项目:permissionsModule    文件ContentResolverCompatJellybean.java   
static boolean isFrameworkOperationCanceledException(Exception e) {
    return e instanceof OperationCanceledException;
}
项目:MyCTFWriteUps    文件ContentResolverCompatJellybean.java   
static boolean isFrameworkOperationCanceledException(Exception exception)
{
    return exception instanceof OperationCanceledException;
}
项目:android-observable-list    文件OperationCanceledExceptionCompat.java   
@Override
public RuntimeException create() {
    return new OperationCanceledException();
}
项目:android-oauth-client    文件OAuthManagerTest.java   
@Test
public void testnormalTaskExecution() throws OperationCanceledException,IOException {
    OAuthFuture<String> future = mock.runTest(null,null);
    String result = future.getResult();
    assertEquals("ok",result);
}
项目:android-oauth-client    文件OAuthManagerTest.java   
public String getResult() throws OperationCanceledException,IOException {
    return future.getResult();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。