项目作者: shubhamvashisht

项目描述 :
Toasty library Kotlin version with Kotlin Extensions
高级语言: Kotlin
项目地址: git://github.com/shubhamvashisht/KToasty.git
创建时间: 2018-06-10T19:22:59Z
项目社区:https://github.com/shubhamvashisht/KToasty

开源协议:GNU Lesser General Public License v3.0

下载


KToasty

Toasty library Kotlin variant with added sweetness of kotlin extensions.

This library was forked from Toasty and is a rewrite of same in kotlin with added kotlin extensions.

Prerequisites

Add this in your root build.gradle file (not your module build.gradle file):

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }

Dependency

Add this to your module’s build.gradle file (make sure the version matches the JitPack badge above):

  1. dependencies {
  2. ...
  3. implementation 'com.github.shubhamvashisht:KToasty:1.0'
  4. }

Usage

Each method always returns a Toast object, so you can customize the Toast much more. DON’T FORGET THE show() METHOD!

For an error toast:

  1. KToasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show()

For a success toast:

  1. KToasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show()

For an info toast:

  1. KToasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show()

For an warning toast:

  1. KToasty.warning(yourContext, "Beware of the dog.", Toast.LENGTH_SHORT, true).show()

For a normal toast:

  1. KToasty.normal(yourContext, "Normal toast w/o icon").show()

For a normal toast with an icon:

  1. KToasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show()

Using Extensions

You can use extensions to quickly show the toasts. just call extensions on any context.
For example. You don’t need to call show() explicitly.

In your activity

  1. //normal toast
  2. this.showNormalToast("message", Toast.LENGTH_SHORT)

or

  1. //success toast with default icon
  2. this.showSuccessToast("message", Toast.LENGTH_SHORT, true)

In your Fragment

  1. //normal toast
  2. getActivity().showNormalToast("message", Toast.LENGTH_SHORT)

or

  1. //error toast with default icon
  2. getActivity().showErrorToast("error message", Toast.LENGTH_SHORT, true)
More extensions coming for full custom toasts.

Screenshots

Screenshots

Contributions and issues

Please report and open issue if you find any.
Contributions are always welcome. To contribute, simply open up a PR with the changes.