A simple library to generate custom loading screens using Lottie Files (till your application fetches data from server)
if your gradle version is 7.0 or above :
Add this to your settings.gradle (Project level):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
....
maven { url 'https://jitpack.io' }
}
}
If your gradle version is below 7.0 : Add this to your build.gradle (Project level):
allprojects {
repositories {
....
maven { url 'https://jitpack.io' }
}
}
enable view-binding in your app/build.gradle (Module level):
android {
....
buildFeatures {
viewBinding true
}
}
Add the dependencies in your app/build.gradle:
dependencies {
....
implementation "com.github.sakshampruthi:custom-loading-screen:1.16"
}
To use the loading screen you need a LottieAnimation file.
Find one that suits you here and download the corresponding lottie json.
Place the json file in res->raw
Next step is to call the showDialog()
:
For kotlin:
showDialog(context, //context or this
true, //dismiss dialog onBackPressed
R.raw.<lottiejson> //lottie file json stored in res/raw
)
For Java:
LoaderKt.showDialog(this,
true,
<lottiejson>
)
To dismiss the view:
For kotlin:
hideDialog()
For Java:
LoaderKt.hideDialog()