LottieDialog

Additional

Language
Java
Version
1.0.0 (Oct 22, 2021)
Created
Oct 21, 2021
Updated
Jul 16, 2022 (Retired)
Owner
Amr Hesham (AmrDeveloper)
Contributor
Amr Hesham (AmrDeveloper)
1
Activity
Badge
Generate
Download
Source code

LottieDialog

Android Library to create Lottie animation view dialog easily with a lot of customization

Why you should use Lottie Dialog

  • You have no limited type of dialog, you create your own types and using them.
  • You don't need to add unused file in your project, just add what you will use.
  • You can add any number of buttons and customize them as you want.
  • Customize dialog title as you want, change color, size and visibility.
  • Customize dialog message as you want, change color, size and visibility.
  • You can change your dialog width and height by number of by percentage.
  • You can change the animation view width and height.
  • Set your animation easily from assets, raw resources or URLs.
  • And more...

Download or create Lottie animation file

Add Lottie Dialog to your project

From Maven Central

implementation 'io.github.amrdeveloper:lottiedialog:1.0.0'
Or Add LottieDialog from Jitpack.io

Add it in your root build.gradle at the end of repositories

allprojects {
    repositories {
         maven { url 'https://jitpack.io' }
    }
}

Add the dependency

implementation 'com.github.amrdeveloper:lottiedialog:1.0.0'

And sync the Gradle.

Code Example

Button okButton = new Button(this);
okButton.setText("Ok");
okButton.setOnClickListener(view -> {});

Button cancelButton = new Button(this);
cancelButton.setText("Cancel");
cancelButton.setOnClickListener(view -> {});

LottieDialog dialog = new LottieDialog(this)
    .setAnimation(R.raw.animation)
    .setAnimationRepeatCount(LottieDialog.INFINITE)
    .setAutoPlayAnimation(true)
    .setTitle("Title")
    .setTitleColor(Color.WHITE)
    .setMessage("Message...")
    .setMessageColor(Color.WHITE)
    .setDialogBackground(Color.BLACK)
    .setCancelable(false)
    .addActionButton(okButton)
    .addActionButton(cancelButton)
    .setOnShowListener(dialogInterface -> {})
    .setOnDismissListener(dialogInterface -> {})
    .setOnCancelListener(dialogInterface -> {});
dialog.show();

Documentation

Lottie Dialog was designed with a fluent interface concept and with the goal to make it customizable as much as we can

Set dialog title.

setTitle(String title);

Set dialog title color.

setTitleColor(int color)

Set dialog title text size.

setTitleTextSize(float size)

Set dialog title visibility, the default value is View.VISIBLE.

setTitleVisibility(int visibility)

Set dialog message.

setMessage(String message)

Set dialog message text size.

setMessageTextSize(float size)

Set message visibility, the default value is View.VISIBLE.

setMessageVisibility(int visibility)

Set dialog background color.

setDialogBackground(int color)

Set dialog background drawable.

setDialogBackgroundDrawable(Drawable drawable)

Set dialog dim amount.

setDialogDimAmount(float amount)

Set dialog cancelable.

setCancelable(boolean cancelable)

Set dialog canceled on touch outside.

setCanceledOnTouchOutside(boolean cancel)

Set dialog height.

setDialogHeight(int height)

Set dialog width.

setDialogWidth(int width)

Set dialog height by percentage, for example 0.50f for 50%.

setDialogHeightPercentage(float percentage)

Set dialog width by percentage, for example 0.50f for 50%.

setDialogWidthPercentage(float percentage)

Set Lottie animation view height.

setAnimationViewHeight(int height)

Set Lottie animation view width.

setAnimationViewWidth(int width)

Set animation from raw resources.

setAnimation(@RawRes int rawRes)

Set animation from Animation object.

setAnimation(Animation animation)

Set animation from assets folder

setAnimation(String assetName)

Set animation from URL, need INTERNET permission

setAnimationFromUrl(String url)

Set repeat count for the animation, for indefinitely use LottieDialog.INFINITE

setAnimationRepeatCount(int count)

Set animation speed

setAnimationSpeed(float speed)

Add action button, you should set listeners and customize it then add it to Lottie dialog

addActionButton(Button button)

Add action button with the index

addActionButton(Button button, int index)

Control auto play animation when the dialog is showing

setAutoPlayAnimation(boolean autoplay)

Check animation auto playing value

isAutoPlayedAnimation()

Play the animation.

playAnimation()

Pause the animation.

pauseAnimation()

cancel the animation.

cancelAnimation()

clear the animation.

clearAnimation()

reverse the animation speed.

reverseAnimationSpeed()

Check if is animating or not.

isAnimating()

Show Lottie dialog.

show()

Check if Lottie dialog is showing.

isShowinng()

Dismiss Lottie dialog.

dismiss()

Cancel Lottie dialog`.

cancel()

Listen when Lottie dialog is showing.

setOnShowListener(DialogInterface.OnShowListener listener)

Listen when Lottie dialog is canceled.

setOnCancelListener(DialogInterface.OnCancelListener listener)

Listen when Lottie dialog is dismissed.

setOnDismissListener(DialogInterface.OnDismissListener listener)

How to contribute

  • You are most welcome to request features, report bugs by creating a new issues.
  • Before starting implementing the feature please make sure the issue is approved and assigned to you.

License

MIT License

Copyright (c) 2021 Amr Hesham

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.