Java源码示例:android.support.v4.os.CancellationSignal

示例1
public void begin(NavigationScene navigationScene, Scene from, Scene to) {
    this.mStart = true;
    this.mNavigationScene = navigationScene;
    this.mFromScene = from;
    this.mToScene = to;
    this.mAnimationList = onPopInteraction(from, to);

    if (mCallback != null) {
        this.mAnimationList.add(new CallbackProgressProxyInteractionAnimation(1.0f));
    }

    this.mToScreenViewVisibility = this.mToScene.getView().getVisibility();
    this.mToScene.getView().setVisibility(View.VISIBLE);
    this.mFromSceneBackground = this.mFromScene.getView().getBackground();
    ViewCompat.setBackground(this.mFromScene.getView(), null);

    mCancellationSignal = new CancellationSignal();
    mCancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {
        @Override
        public void onCancel() {
            forceCancel();
        }
    });
    sCancellationSignal = mCancellationSignal;

    if (this.mCallback != null) {
        this.mCallback.onStart();
    }
}
 
示例2
/**
 * This is especially error-prone, so the ViewTreeObserver parameter is mandatory.
 * <p>
 * If a View does not have attachedWindow(), the getViewTreeObserver is created internally by itself,
 * and ready to be merged into the system when attachedToWindow.
 * But if you need to remove this View in somewhere (such as Scene's own lifecycle)
 * Then there is no way to getViewTreeObserver.removeOnPreDrawListener(this)
 */
public static void executeImmediatelyOrOnPreDraw(@NonNull final View view, @NonNull final ViewTreeObserver viewTreeObserver, boolean force, @NonNull final CancellationSignal cancellationSignal, @NonNull final Runnable action) {
    if (view == null) {
        throw new NullPointerException("view can't be null");
    }
    if (viewTreeObserver == null) {
        throw new NullPointerException("viewTreeObserver can't be null");
    }
    if (action == null) {
        throw new NullPointerException("action can't be null");
    }
    if (force || view.getWidth() > 0 && view.getHeight() > 0) {
        action.run();
    } else {
        viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                viewTreeObserver.removeOnPreDrawListener(this);
                if (!cancellationSignal.isCanceled()) {
                    action.run();
                    return true;
                } else {
                    return false;
                }
            }
        });
        view.invalidate();
    }
}
 
示例3
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags,
            cancel != null ? cancel.getCancellationSignalObject() : null,
            wrapCallback(callback), handler);
}
 
示例4
private void init(Context context) {
    failedCount = 0;

    authenticationCallback = new FingerprintManagerCompat.AuthenticationCallback() {
        @Override
        public void onAuthenticationFailed() {
            failedCount++;
            if (failedCount == maxFailedCount) {
                failedCount = 0;
                if (onFingerAuthListener != null) {
                    cancelSignal();
                    onFingerAuthListener.onError();
                }
            } else {
                onFingerAuthListener.onFailure();
            }
        }

        @Override
        public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) {
            if (onFingerAuthListener != null) {
                cancelSignal();
                onFingerAuthListener.onSuccess();
            }
        }
    };

    fingerprintManagerCompat = FingerprintManagerCompat.from(context);
    cancellationSignal = new CancellationSignal();

    fingerprintManagerCompat.authenticate(null, 0, cancellationSignal, authenticationCallback, null);
}
 
示例5
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags,
            cancel != null ? cancel.getCancellationSignalObject() : null,
            wrapCallback(callback), handler);
}
 
示例6
public Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    Object cancellationSignalObject;
    if (cancellationSignal != null) {
        try {
            cancellationSignalObject = cancellationSignal.getCancellationSignalObject();
        } catch (Exception e) {
            if (ContentResolverCompatJellybean.isFrameworkOperationCanceledException(e)) {
                throw new OperationCanceledException();
            }
            throw e;
        }
    }
    cancellationSignalObject = null;
    return ContentResolverCompatJellybean.query(resolver, uri, projection, selection, selectionArgs, sortOrder, cancellationSignalObject);
}
 
示例7
public Cursor loadInBackground() {
    Cursor cursor;
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        this.mCancellationSignal = new CancellationSignal();
    }
    try {
        cursor = ContentResolverCompat.query(getContext().getContentResolver(), this.mUri, this.mProjection, this.mSelection, this.mSelectionArgs, this.mSortOrder, this.mCancellationSignal);
        if (cursor != null) {
            cursor.getCount();
            cursor.registerContentObserver(this.mObserver);
        }
        synchronized (this) {
            this.mCancellationSignal = null;
        }
        return cursor;
    } catch (RuntimeException ex) {
        cursor.close();
        throw ex;
    } catch (Throwable th) {
        synchronized (this) {
            this.mCancellationSignal = null;
        }
    }
}
 
示例8
public void startListening(FingerprintManagerCompat.CryptoObject cryptoObject) {
    if (!mListening) {
        mListening = true;
        mCancellationSignal = new CancellationSignal();
        mSelfCancelled = false;
        mFingerprintManagerCompat
                .authenticate(cryptoObject, 0, mCancellationSignal, this, null);
        mSwirlView.setState(SwirlView.State.ON);
    }
}
 
示例9
void authenticate(Context context, CryptoObject crypto, int flags,
CancellationSignal cancel, AuthenticationCallback callback, Handler handler);
 
示例10
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    // TODO: Figure out behavior when there is no fingerprint hardware available
}
 
示例11
void authenticate(Context context, CryptoObject crypto, int flags,
CancellationSignal cancel, AuthenticationCallback callback, Handler handler);
 
示例12
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    // TODO: Figure out behavior when there is no fingerprint hardware available
}
 
示例13
public Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    if (cancellationSignal != null) {
        cancellationSignal.throwIfCanceled();
    }
    return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
}
 
示例14
public static Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    return IMPL.query(resolver, uri, projection, selection, selectionArgs, sortOrder, cancellationSignal);
}
 
示例15
public void authenticate(Context context, CryptoObject crypto, int flags, CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags, cancel != null ? cancel.getCancellationSignalObject() : null, wrapCallback(callback), handler);
}
 
示例16
public void authenticate(Context context, CryptoObject crypto, int flags, CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
}
 
示例17
public void authenticate(@Nullable CryptoObject crypto, int flags, @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
    IMPL.authenticate(this.mContext, crypto, flags, cancel, callback, handler);
}
 
示例18
/**
 * Request authentication of a crypto object. This call warms up the fingerprint hardware
 * and starts scanning for a fingerprint. It terminates when
 * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)} or
 * {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult) is called, at
 * which point the object is no longer valid. The operation can be canceled by using the
 * provided cancel object.
 *
 * @param crypto object associated with the call or null if none required.
 * @param flags optional flags; should be 0
 * @param cancel an object that can be used to cancel authentication
 * @param callback an object to receive authentication events
 * @param handler an optional handler for events
 */
public void authenticate(@Nullable CryptoObject crypto, int flags,
                         @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback,
                         @Nullable Handler handler) {
    IMPL.authenticate(mContext, crypto, flags, cancel, callback, handler);
}
 
示例19
/**
 * Request authentication of a crypto object. This call warms up the fingerprint hardware
 * and starts scanning for a fingerprint. It terminates when
 * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)} or
 * {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult) is called, at
 * which point the object is no longer valid. The operation can be canceled by using the
 * provided cancel object.
 *
 * @param crypto object associated with the call or null if none required.
 * @param flags optional flags; should be 0
 * @param cancel an object that can be used to cancel authentication
 * @param callback an object to receive authentication events
 * @param handler an optional handler for events
 */
public void authenticate(@Nullable CryptoObject crypto, int flags,
                         @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback,
                         @Nullable Handler handler) {
    IMPL.authenticate(mContext, crypto, flags, cancel, callback, handler);
}
 
示例20
Cursor query(ContentResolver contentResolver, Uri uri, String[] strArr, String str, String[] strArr2, String str2, CancellationSignal cancellationSignal); 
示例21
void authenticate(Context context, CryptoObject cryptoObject, int i, CancellationSignal cancellationSignal, AuthenticationCallback authenticationCallback, Handler handler);