edgar-zigis / SlidingToast

Fancy way to display animated toasts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SlidingToast Maven Central

A fancy way to display Android toasts! Based on https://github.com/AviranAbady/CookieBar2, however this version is lightweight without custom view inflation etc.

Minimum target SDK: 17. RTL SUPPORTED.

alt text

Gradle

Make sure you have Maven Central included in your gradle repositories.

allprojects {
    repositories {
        mavenCentral()
    }
}
implementation 'com.bio-matic:slidingtoast:1.0.4'

Usage

SlidingToast.build(this)
    .setIcon(R.drawable.ic_warning)
    .setMessage(R.string.top_toast_message)
    .setBackgroundColor(R.color.colorRed)
    .setDuration(4000)
    .setDismissListener(object : SlidingToastDismissListener {
        override fun onDismiss(dismissType: Int) {
            val description = when (dismissType) {
                DURATION_COMPLETE -> "Toast display duration completed"
                USER_DISMISS -> "Toast dismissed by user"
                PROGRAMMATIC_DISMISS -> "Toast dismissed programmatically"
                REPLACE_DISMISS -> "Replaced by new Toast"
                else -> "Other"
            }
            Toast.makeText(this@MainActivity, description, Toast.LENGTH_LONG).show()
        }
    })
    .show()

About

Fancy way to display animated toasts

License:MIT License


Languages

Language:Kotlin 100.0%