diff options
Diffstat (limited to 'java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java')
-rw-r--r-- | java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java index 36af62245..f2ff0e3e3 100644 --- a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java +++ b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java @@ -24,6 +24,9 @@ import android.support.annotation.Nullable; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.common.concurrent.UiListener; +import com.android.dialer.function.Consumer; import com.android.dialer.logging.DialerImpression.Type; import com.android.dialer.logging.Logger; import com.android.dialer.precall.PreCallAction; @@ -31,6 +34,9 @@ import com.android.dialer.precall.PreCallComponent; import com.android.dialer.precall.PreCallCoordinator; import com.android.dialer.telecom.TelecomUtil; import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; /** * Implements {@link PreCallCoordinator}. Listens to the life cycle of {@link PreCallActivity} to @@ -49,6 +55,8 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator { private PendingAction pendingAction; private boolean aborted = false; + private UiListener<Object> uiListener; + PreCallCoordinatorImpl(@NonNull Activity activity) { this.activity = Assert.isNotNull(activity); } @@ -61,6 +69,9 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator { } else { builder = Assert.isNotNull(intent.getParcelableExtra(EXTRA_CALL_INTENT_BUILDER)); } + uiListener = + DialerExecutorComponent.get(activity) + .createUiListener(activity.getFragmentManager(), "PreCallCoordinatorImpl.uiListener"); } void onRestoreInstanceState(Bundle savedInstanceState) { @@ -152,4 +163,18 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator { onActionFinished(); } } + + @SuppressWarnings("unchecked") + @Override + public <OutputT> void listen( + ListenableFuture<OutputT> future, + Consumer<OutputT> successListener, + Consumer<Throwable> failureListener) { + + uiListener.listen( + activity, + Futures.transform(future, (output) -> (Object) output, MoreExecutors.directExecutor()), + output -> successListener.accept((OutputT) output), + failureListener::accept); + } } |