ConfirmationOverlay

public class ConfirmationOverlay


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

This is a lighter-weight version of 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 DEFAULT_ANIMATION_DURATION_MS
  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 types

ConfirmationOverlay.OnAnimationFinishedListener

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

ConfirmationOverlay.OverlayType

Types of animations to display in the overlay.

Constants

static final @NonNull int

Default animation duration in ms.

static final @NonNull int

OverlayType indicating the failure overlay should be shown.

static final @NonNull int

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

static final @NonNull int

OverlayType indicating the success animation overlay should be displayed.

Public methods

@NonNull ConfirmationOverlay
setDuration(@NonNull int millis)

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

@NonNull ConfirmationOverlay

This method is deprecated.

Use setOnAnimationFinishedListener instead.

@NonNull ConfirmationOverlay

This method is deprecated.

Use setMessage instead.

@NonNull ConfirmationOverlay

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

@NonNull ConfirmationOverlay

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

@NonNull ConfirmationOverlay

Sets the OverlayType which controls which animation is displayed.

@MainThread @NonNull void

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

@MainThread @NonNull void
showOn(@NonNull Activity activity)

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

Constants

DEFAULT_ANIMATION_DURATION_MS

@NonNull
public static final @NonNull int DEFAULT_ANIMATION_DURATION_MS

Default animation duration in ms.

FAILURE_ANIMATION

@NonNull
public static final @NonNull int FAILURE_ANIMATION

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

OPEN_ON_PHONE_ANIMATION

@NonNull
public static final @NonNull int OPEN_ON_PHONE_ANIMATION

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

SUCCESS_ANIMATION

@NonNull
public static final @NonNull int SUCCESS_ANIMATION

OverlayType indicating the success animation overlay should be displayed.

Public methods

setDuration

@NonNull
public ConfirmationOverlay setDuration(@NonNull int millis)

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

Returns
ConfirmationOverlay

this object for method chaining.

setFinishedAnimationListener

@NonNull
public ConfirmationOverlay setFinishedAnimationListener(
    @Nullable ConfirmationOverlay.OnAnimationFinishedListener listener
)

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

Returns
ConfirmationOverlay

this object for method chaining.

setMessage

@NonNull
public ConfirmationOverlay setMessage(@NonNull String message)

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

Returns
ConfirmationOverlay

this object for method chaining.

setMessage

@NonNull
public ConfirmationOverlay setMessage(@