Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3dce5bd authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Changes transaction Listener to OnCompleteListener

Bug: 67734082
Test: None
Change-Id: I7a7b1b448d3a4eeed57fabd333c35faa18c7443d
parent ac7b959b
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import java.util.concurrent.TimeoutException;
 * through the ContextHubManager APIs. The caller can either retrieve the result
 * synchronously through a blocking call ({@link #waitForResponse(long, TimeUnit)}) or
 * asynchronously through a user-defined listener
 * ({@link #setOnCompleteListener(Listener, Executor)} )}).
 * ({@link #setOnCompleteListener(OnCompleteListener, Executor)} )}).
 *
 * @param <T> the type of the contents in the transaction response
 *
@@ -153,7 +153,7 @@ public class ContextHubTransaction<T> {
     * @param <L> the type of the contents in the transaction response
     */
    @FunctionalInterface
    public interface Listener<L> {
    public interface OnCompleteListener<L> {
        /**
         * The listener function to invoke when the transaction completes.
         *
@@ -183,7 +183,7 @@ public class ContextHubTransaction<T> {
    /*
     * The listener to be invoked when the transaction completes.
     */
    private ContextHubTransaction.Listener<T> mListener = null;
    private ContextHubTransaction.OnCompleteListener<T> mListener = null;

    /*
     * Synchronization latch used to block on response.
@@ -274,8 +274,8 @@ public class ContextHubTransaction<T> {
     * A transaction can be invalidated if the process owning the transaction is no longer active
     * and the reference to this object is lost.
     *
     * This method or {@link #setOnCompleteListener(ContextHubTransaction.Listener)} can only be
     * invoked once, or an IllegalStateException will be thrown.
     * This method or {@link #setOnCompleteListener(ContextHubTransaction.OnCompleteListener)} can
     * only be invoked once, or an IllegalStateException will be thrown.
     *
     * @param listener the listener to be invoked upon completion
     * @param executor the executor to invoke the callback
@@ -284,10 +284,10 @@ public class ContextHubTransaction<T> {
     * @throws NullPointerException if the callback or handler is null
     */
    public void setOnCompleteListener(
            @NonNull ContextHubTransaction.Listener<T> listener,
            @NonNull ContextHubTransaction.OnCompleteListener<T> listener,
            @NonNull @CallbackExecutor Executor executor) {
        synchronized (this) {
            Preconditions.checkNotNull(listener, "Listener cannot be null");
            Preconditions.checkNotNull(listener, "OnCompleteListener cannot be null");
            Preconditions.checkNotNull(executor, "Executor cannot be null");
            if (mListener != null) {
                throw new IllegalStateException(
@@ -306,18 +306,19 @@ public class ContextHubTransaction<T> {
    /**
     * Sets the listener to be invoked invoked when the transaction completes.
     *
     * Equivalent to {@link #setOnCompleteListener(ContextHubTransaction.Listener, Executor)}
     * with the executor using the main thread's Looper.
     * Equivalent to {@link #setOnCompleteListener(ContextHubTransaction.OnCompleteListener,
     * Executor)} with the executor using the main thread's Looper.
     *
     * This method or {@link #setOnCompleteListener(ContextHubTransaction.Listener, Executor)}
     * can only be invoked once, or an IllegalStateException will be thrown.
     * This method or {@link #setOnCompleteListener(ContextHubTransaction.OnCompleteListener,
     * Executor)} can only be invoked once, or an IllegalStateException will be thrown.
     *
     * @param listener the listener to be invoked upon completion
     *
     * @throws IllegalStateException if this method is called multiple times
     * @throws NullPointerException if the callback is null
     */
    public void setOnCompleteListener(@NonNull ContextHubTransaction.Listener<T> listener) {
    public void setOnCompleteListener(
            @NonNull ContextHubTransaction.OnCompleteListener<T> listener) {
        setOnCompleteListener(listener, new HandlerExecutor(Handler.getMain()));
    }