android.database.sqlite.SQLiteTransactionListener

Here are the examples of the java api class android.database.sqlite.SQLiteTransactionListener taken from open source projects.

1. SQLiteSession#yieldTransactionUnchecked()

Project: sqlite-android
File: SQLiteSession.java
private boolean yieldTransactionUnchecked(long sleepAfterYieldDelayMillis, CancellationSignal cancellationSignal) {
    if (cancellationSignal != null) {
        cancellationSignal.throwIfCanceled();
    }
    if (!mConnectionPool.shouldYieldConnection(mConnection, mConnectionFlags)) {
        return false;
    }
    final int transactionMode = mTransactionStack.mMode;
    final SQLiteTransactionListener listener = mTransactionStack.mListener;
    final int connectionFlags = mConnectionFlags;
    // might throw
    endTransactionUnchecked(cancellationSignal, true);
    if (sleepAfterYieldDelayMillis > 0) {
        try {
            Thread.sleep(sleepAfterYieldDelayMillis);
        } catch (InterruptedException ex) {
        }
    }
    beginTransactionUnchecked(transactionMode, listener, connectionFlags, // might throw
    cancellationSignal);
    return true;
}

2. SQLiteSession#endTransactionUnchecked()

Project: sqlite-android
File: SQLiteSession.java
private void endTransactionUnchecked(CancellationSignal cancellationSignal, boolean yielding) {
    if (cancellationSignal != null) {
        cancellationSignal.throwIfCanceled();
    }
    final Transaction top = mTransactionStack;
    boolean successful = (top.mMarkedSuccessful || yielding) && !top.mChildFailed;
    RuntimeException listenerException = null;
    final SQLiteTransactionListener listener = top.mListener;
    if (listener != null) {
        try {
            if (successful) {
                // might throw
                listener.onCommit();
            } else {
                // might throw
                listener.onRollback();
            }
        } catch (RuntimeException ex) {
            listenerException = ex;
            successful = false;
        }
    }
    mTransactionStack = top.mParent;
    recycleTransaction(top);
    if (mTransactionStack != null) {
        if (!successful) {
            mTransactionStack.mChildFailed = true;
        }
    } else {
        try {
            if (successful) {
                // might throw
                mConnection.execute("COMMIT;", null, cancellationSignal);
            } else {
                // might throw
                mConnection.execute("ROLLBACK;", null, cancellationSignal);
            }
        } finally {
            // might throw
            releaseConnection();
        }
    }
    if (listenerException != null) {
        throw listenerException;
    }
}