ConfirmationOverlay

Added in 1.1.0

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

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

@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = )
public annotation ConfirmationOverlay.OverlayType

Types of animations to display in the overlay.

Constants

static final int

Default animation duration in ms.

static final int

OverlayType indicating the failure overlay should be shown.

static final int

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

static final int

OverlayType indicating the success animation overlay should be displayed.

Public constructors

Public methods

@NonNull ConfirmationOverlay
setDuration(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

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

@NonNull ConfirmationOverlay

This method is deprecated.

Use setMessage instead.

@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.

void

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

void

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

Constants

DEFAULT_ANIMATION_DURATION_MS

Added in 1.1.0
public static final int DEFAULT_ANIMATION_DURATION_MS = 1000

Default animation duration in ms.

FAILURE_ANIMATION

Added in 1.1.0
public static final int FAILURE_ANIMATION = 1

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

OPEN_ON_PHONE_ANIMATION

Added in 1.1.0
public static final int OPEN_ON_PHONE_ANIMATION = 2

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

SUCCESS_ANIMATION

Added in 1.1.0
public static final int SUCCESS_ANIMATION = 0

OverlayType indicating the success animation overlay should be displayed.

Public constructors

ConfirmationOverlay

Added in 1.1.0
public ConfirmationOverlay()

Public methods

setDuration

Added in 1.1.0
public @NonNull ConfirmationOverlay setDuration(int millis)

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

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

setFinishedAnimationListener

Added in 1.1.0
Deprecated in 1.1.0
public @NonNull ConfirmationOverlay setFinishedAnimationListener(
    @Nullable ConfirmationOverlay.OnAnimationFinishedListener listener
)

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

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

setMessage

Added in 1.1.0
public @NonNull ConfirmationOverlay setMessage(@NonNull CharSequence message)

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

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

setMessage

Added in 1.1.0
Deprecated in 1.1.0
public @NonNull ConfirmationOverlay setMessage(@NonNull String message)

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

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

setOnAnimationFinishedListener

Added in 1.1.0
public @NonNull ConfirmationOverlay setOnAnimationFinishedListener(
    @Nullable ConfirmationOverlay.OnAnimationFinishedListener listener
)

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

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

setType

Added in 1.1.0
public @NonNull ConfirmationOverlay setType(@ConfirmationOverlay.OverlayType int type)

Sets the OverlayType which controls which animation is displayed.

Returns
@NonNull ConfirmationOverlay

this object for method chaining.

showAbove

Added in 1.1.0
@MainThread
public void showAbove(@NonNull View view)

Adds the overlay as a child of view.getRootView(), removing it when complete. While it is shown, all touches will be intercepted to prevent accidental taps on obscured views.

showOn

Added in 1.1.0
@MainThread
public void showOn(@NonNull Activity activity)

Adds the overlay as a content view to the activity, removing it when complete. While it is shown, all touches will be intercepted to prevent accidental taps on obscured views.