All Projects → bboylin → Universaltoast

bboylin / Universaltoast

简洁优雅可点击的toast控件,无BadTokenException风险,关闭通知权限依然正常显示。An elegant and flexible toast which can handle click event , avoid BadTokenException and run fine without notification permission

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Universaltoast

Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+3942.65%)
Mutual labels:  permission, toast
Devutils
🔥 ( 持续更新,目前含 160+ 工具类 ) DevUtils 是一个 Android 工具库,主要根据不同功能模块,封装快捷使用的工具类及 API 方法调用。该项目尽可能的便于开发人员,快捷、高效开发安全可靠的项目。
Stars: ✭ 680 (-9.09%)
Mutual labels:  permission, toast
Cookiebar2
Android library for displaying text messages, notifications and alerts at the top or bottom of the screen. A great alternative for toast and snackbar alerts.
Stars: ✭ 499 (-33.29%)
Mutual labels:  toast
Dialog
🔥空祖家的对话框工具
Stars: ✭ 658 (-12.03%)
Mutual labels:  toast
Csvs To Sqlite
Convert CSV files into a SQLite database
Stars: ✭ 568 (-24.06%)
Mutual labels:  click
Casbin.net
An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
Stars: ✭ 535 (-28.48%)
Mutual labels:  permission
Popupview
Toasts and popups library written with SwiftUI
Stars: ✭ 581 (-22.33%)
Mutual labels:  toast
Xtoast
Android 悬浮窗框架,好用不解释
Stars: ✭ 493 (-34.09%)
Mutual labels:  toast
Toasty
The usual Toast, but with steroids 💪
Stars: ✭ 6,279 (+739.44%)
Mutual labels:  toast
Cogo Toast
Beautiful, Zero Configuration, Toast Messages for React. Only ~ 4kb gzip, with styles and icons
Stars: ✭ 557 (-25.53%)
Mutual labels:  toast
Fftoast
A very powerful iOS message notifications and AlertView extensions. It can be easily realized from the top of the screen, the bottom of the screen and the middle of the screen pops up a notification. You can easily customize the pop-up View.
Stars: ✭ 649 (-13.24%)
Mutual labels:  toast
Dtoast
同学,你的系统Toast可能需要修复一下!Fix Your Android Toast!
Stars: ✭ 556 (-25.67%)
Mutual labels:  toast
Needs
🌂 An easy way to implement modern permission instructions popup.
Stars: ✭ 546 (-27.01%)
Mutual labels:  permission
Gsmessages
A simple style messages/notifications, in Swift.
Stars: ✭ 595 (-20.45%)
Mutual labels:  toast
Toast Phonegap Plugin
🍻 A Toast popup plugin for your fancy Cordova app
Stars: ✭ 503 (-32.75%)
Mutual labels:  toast
Cookiebar
CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen.
Stars: ✭ 497 (-33.56%)
Mutual labels:  toast
Bot toast
A really easy to use flutter toast library
Stars: ✭ 551 (-26.34%)
Mutual labels:  toast
Toastify Js
Pure JavaScript library for better notification messages
Stars: ✭ 570 (-23.8%)
Mutual labels:  toast
Anylayer
Android稳定高效的浮层创建管理框架
Stars: ✭ 745 (-0.4%)
Mutual labels:  toast
Sweet Alert
A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL
Stars: ✭ 696 (-6.95%)
Mutual labels:  toast

UniversalToast:一个简洁优雅的toast组件,支持点击和GIF&安全

features

  • 优雅 & 灵活
  • 可点击 & 可随意设置显示时长
  • 主动避免android 7.0使用toast可能出现的BadTokenException
  • 关闭通知权限后依然可以正常弹出
  • 支持加载GIF,让你的toast更生动

Usages

  • step 1 : 添加依赖
allprojects {
    repositories {
        ......
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    ......
    implementation 'com.github.bboylin:UniversalToast:v1.0.9'
    // 请添加上fresco的依赖,可以把fresco版本替换成最新的
    implementation 'com.facebook.fresco:fresco:1.10.0'
    implementation 'com.facebook.fresco:animated-gif:1.10.0'
}
  • step 2 : api类似原生toast
UniversalToast.makeText(context, text, duration).show();
UniversalToast.makeText(context, text, duration,type).show();

duration 应该是UniversalToast.LENGTH_LONGUniversalToast.LENGTH_SHORT其中之一, type 应该是 UniversalToast.UNIVERSAL , UniversalToast.EMPHASIZE , UniversalToast.CLICKABLE 三者之一 , 未指定则默认为 UniversalToast.UNIVERSAL.

从左到右依次为UNIVERSALEMPHASIZECLICKABLE样式的toast,图标文字可设置。

  • 更多API:

设置duration和设置动画的方法被废弃掉了,因为:

  • 不建议自己修改toast显示时长
  • 在android framework里限制了windowAnimations必须是系统动画。
//example
UniversalToast.makeText(context, text, UniversalToast.LENGTH_SHORT, UniversalToast.CLICKABLE)
              .setGravity(gravity,xOffset,yOffset)
              .setBackground(drawable) // 设置背景
              .setColor(R.color.my_color) // 设置背景色
              .setLeftIconRes(R.drawable.my_ic) // 设置icon,未调用的话icon不可见(gone)
              .setLeftGifUri(uri) // 设置gif的uri,设置后setLeftIconRes方法会失效,即优先展示gif
              .setClickCallback(text,R.drawable.my_btn,onClickListener) //设置点击listener
              .show();

有三种默认的图标提供,用showSuccess(),showWarning()showError()代替show()即可采用对应的图标。

从左到右依次为 : showSuccessshowWarningshowError 的图标(这里只展示了EMPHASIZE类型的toast,CLICKABLEUNIVERSAL亦可)

注意:

由于Android 8.0对悬浮窗权限的限制,使用可点击的toast(即UniversalToast.CLICKABLE)必须允许悬浮窗权限:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

关于如何动态申请权限请参考demo。 Android 8.0以下无需悬浮窗权限。

minSdkVersion>=14

notice :

如果你遇到activity finish的时候toast cancel出现bug:

请将此处你的application context改为activity的context

感谢 : ToastCompat

更新:

没想到有这么多人没用过fresco。。。在application初始化的时候记得初始化fresco:

Fresco.initialize(ctx);

不想引入fresco就把版本换成1.0.8

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].