Android 12 Developer Preview is here! Try it out, and give us your feedback!

ConfirmationOverlay

open class ConfirmationOverlay
kotlin.Any
   ↳ androidx.wear.widget.ConfirmationOverlay

Displays a full-screen confirmation animation with optional text and then hides it.

This is a lighter-weight version of androidx.wear.activity.ConfirmationActivity and should be preferred when constructed from an Activity.

Sample usage:

// Defaults to SUCCESS_ANIMATION
    new ConfirmationOverlay().showOn(myActivity);
 
    new ConfirmationOverlay()
       .setType(ConfirmationOverlay.OPEN_ON_PHONE_ANIMATION)
       .setDuration(3000)
       .setMessage("Opening...")
       .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
           @Override
           public void onAnimationFinished() {
               // Finished animating and the content view has been removed from myActivity.
           }
       }).showOn(myActivity);
 
    // Default duration is <code><a docref="androidx.wear.widget.ConfirmationOverlay$DEFAULT_ANIMATION_DURATION_MS">#DEFAULT_ANIMATION_DURATION_MS</a></code>new ConfirmationOverlay()
       .setType(ConfirmationOverlay.FAILURE_ANIMATION)
       .setMessage("Failed")
       .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
           @Override
           public void onAnimationFinished() {
               // Finished animating and the view has been removed from myView.getRootView().
           }
       }).showAbove(myView);
  

Summary

Nested classes
abstract

Interface for listeners to be notified when the ConfirmationOverlay animation has finished and its View has been removed.

Types of animations to display in the overlay.

Constants
static Int

Default animation duration in ms.

static Int

OverlayType indicating the failure overlay should be shown.

static Int

OverlayType indicating the "Open on Phone" animation overlay should be displayed.

static Int

OverlayType indicating the success animation overlay should be displayed.

Public constructors

Displays a full-screen confirmation animation with optional text and then hides it.

Public methods
open ConfirmationOverlay
setDuration(millis: Int)

Sets the duration in milliseconds which controls how long the animation will be displayed.

open ConfirmationOverlay

Sets the OnAnimationFinishedListener which will be invoked once the overlay is no longer visible.

open ConfirmationOverlay
setMessage(@NonNull message: String)

Sets a message which will be displayed at the same time as the animation.

open ConfirmationOverlay
setMessage(@NonNull message: CharSequence)

Sets a message which will be displayed at the same time as the animation.

open ConfirmationOverlay

Sets the OnAnimationFinishedListener which will be invoked once the overlay is no longer visible.

open ConfirmationOverlay
setType(type: Int)

Sets the OverlayType which controls which animation is displayed.

open Unit
showAbove(@NonNull view: View)

Adds the overlay as a child of view.getRootView(), removing it when complete.

open Unit
showOn(@NonNull activity: Activity)

Adds the overlay as a content view to the activity, removing it when complete.

Constants

DEFAULT_ANIMATION_DURATION_MS

static val DEFAULT_ANIMATION_DURATION_MS: Int

Default animation duration in ms.

Value: 1000

FAILURE_ANIMATION

static val FAILURE_ANIMATION: Int

OverlayType indicating the failure overlay should be shown. The icon associated with this type, unlike the others, does not animate.

Value: 1

OPEN_ON_PHONE_ANIMATION

static val OPEN_ON_PHONE_ANIMATION: Int

OverlayType indicating the "Open on Phone" animation overlay should be displayed.

Value: 2

SUCCESS_ANIMATION

static val SUCCESS_ANIMATION: Int

OverlayType indicating the success animation overlay should be displayed.

Value: 0

Public constructors

<init>

ConfirmationOverlay()

Displays a full-screen confirmation animation with optional text and then hides it.

This is a lighter-weight version of androidx.wear.activity.ConfirmationActivity and should be preferred when constructed from an Activity.

Sample usage:

// Defaults to SUCCESS_ANIMATION
    new ConfirmationOverlay().showOn(myActivity);
 
    new ConfirmationOverlay()
       .setType(ConfirmationOverlay.OPEN_ON_PHONE_ANIMATION)
       .setDuration(3000)
       .setMessage("Opening...")
       .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
           @Override
           public void onAnimationFinished() {
               // Finished animating and the content view has been removed from myActivity.
           }
       }).showOn(myActivity);
 
    // Default duration is <code><a docref="androidx.wear.widget.ConfirmationOverlay$DEFAULT_ANIMATION_DURATION_MS">#DEFAULT_ANIMATION_DURATION_MS</a></code>new ConfirmationOverlay()
       .setType(ConfirmationOverlay.FAILURE_ANIMATION)
       .setMessage("Failed")
       .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
           @Override
           public void onAnimationFinished() {
               // Finished animating and the view has been removed from myView.getRootView().
           }
       }).showAbove(myView);
  

Public methods

setDuration

@NonNull open fun setDuration(millis: Int): ConfirmationOverlay

Sets the duration in milliseconds which controls how long the animation will be displayed. Default duration is DEFAULT_ANIMATION_DURATION_MS.

Return
ConfirmationOverlay this object for method chaining.

setFinishedAnimationListener

@NonNull open fun setFinishedAnimationListener(@Nullable listener: ConfirmationOverlay.OnAnimationFinishedListener?): ConfirmationOverlay

Deprecated: Use setOnAnimationFinishedListener(OnAnimationFinishedListener) instead.

Sets the OnAnimationFinishedListener which will be invoked once the overlay is no longer visible.

Return
ConfirmationOverlay this object for method chaining.

setMessage

@NonNull