FileDocCategorySizeDatePackage
UriDerivativeLoader.javaAPI DocAndroid 5.1 API3621Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

UriDerivativeLoader

public abstract class UriDerivativeLoader extends android.content.AsyncTaskLoader
Loader that derives its data from a Uri. Watches for {@link ContentObserver} changes while started, manages {@link CancellationSignal}, and caches returned results.

Fields Summary
final ForceLoadContentObserver
mObserver
private final P
mParam
private R
mResult
private android.os.CancellationSignal
mCancellationSignal
Constructors Summary
public UriDerivativeLoader(android.content.Context context, P param)

        super(context);
        mObserver = new ForceLoadContentObserver();
        mParam = param;
    
Methods Summary
public voidcancelLoadInBackground()

        super.cancelLoadInBackground();

        synchronized (this) {
            if (mCancellationSignal != null) {
                mCancellationSignal.cancel();
            }
        }
    
private voidcloseQuietly(R result)

        if (result instanceof AutoCloseable) {
            try {
                ((AutoCloseable) result).close();
            } catch (RuntimeException rethrown) {
                throw rethrown;
            } catch (Exception ignored) {
            }
        }
    
public voiddeliverResult(R result)

        if (isReset()) {
            closeQuietly(result);
            return;
        }
        R oldResult = mResult;
        mResult = result;

        if (isStarted()) {
            super.deliverResult(result);
        }

        if (oldResult != null && oldResult != result) {
            closeQuietly(oldResult);
        }
    
public final RloadInBackground()

        synchronized (this) {
            if (isLoadInBackgroundCanceled()) {
                throw new OperationCanceledException();
            }
            mCancellationSignal = new CancellationSignal();
        }
        try {
            return loadInBackground(mParam, mCancellationSignal);
        } finally {
            synchronized (this) {
                mCancellationSignal = null;
            }
        }
    
public abstract RloadInBackground(P param, android.os.CancellationSignal signal)

public voidonCanceled(R result)

        closeQuietly(result);
    
protected voidonReset()

        super.onReset();

        // Ensure the loader is stopped
        onStopLoading();

        closeQuietly(mResult);
        mResult = null;

        getContext().getContentResolver().unregisterContentObserver(mObserver);
    
protected voidonStartLoading()

        if (mResult != null) {
            deliverResult(mResult);
        }
        if (takeContentChanged() || mResult == null) {
            forceLoad();
        }
    
protected voidonStopLoading()

        cancelLoad();