1 Star 0 Fork 5

半世浮沉 / PuddingAlert

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Pudding

代替Toast/SnackBar新方式,使用WindowManager 无需申请权限

WIKI

中文说明

Usage

allprojects {
    repositories {
    ...
     maven { url 'https://jitpack.io' }
   implementation 'com.github.o0o0oo00:Pudding:1.2.1'

GIF可能要等会就顺畅了,一开始可能会比较迟钝 (●゚ω゚●)

常见的可配置的几种形式

Common configurable Pudding

Pudding.create(this) {
    setTitle("This is Title")
    setText("this is text")
}.show()
Pudding.create(this) {
    setChocoBackgroundColor(resources.getColor(R.color.colorAccent))
    setTitleTypeface(Typeface.DEFAULT_BOLD)
}.show()
Pudding.create(this) {
    setTitle("Choco Title")
    setText("this is text")
    setIcon(R.drawable.ic_event_available_black_24dp)
}.show()
Pudding.create(this) {
    setTitle("Choco Title")
    setText("This is Text , it's very short and I don't like short \n This is Text , it's very short and I don't like short")
    onShow {
        Toast.makeText(this@MainActivity, "onShowListener", Toast.LENGTH_SHORT).show()
    }
    onDismiss {
        Toast.makeText(this@MainActivity, "onDismissListener", Toast.LENGTH_SHORT).show()
    }
}.show()

配合FancyDialog可实现Pudding显示在Dialog的阴影之上

With FancyDialog, Pudding can be displayed above the shadow of Dialog.

每个Activity拥有各自的Pudding,互相之间不影响

Each Activity has its own Pudding, which does not affect each other.

*Imitate Alerter and ☆⌒(^-゜)v THX!! a lot

what's different

Use activity decorView we can show a view on top of Activity。but when dialog is showing , its black background will cover the view , that is not cool. so i create this repository to solve this problem , and I hope it's useful to you

Something new

  • Use DSL style to config Choco
  • Show Queue
  • Cover Dialog/PopWindow
  • Don't need to request permission

TODO

  1. 两种addView方式

    • activity decorView
    • windowManager
      • 动画显示
      • 生命周期控制
      • 有权限/无权限情况 (考虑到这个需求不是很大,而且每个项目的权限适配都不一致,而且国产手机权限这一块参差不齐,所以决定不做这一块了,对功能也没影响)
      • 各个版本的适配
  2. 内部显示队列(考虑可以使用kotlin通道来实现)

    • 上一条未消失时,后来一条等待
    • 直接顶掉上一条,上一条渐变消失
  3. 左右/上下滑动消失动画

    • 上下消失
    • 左右滑动消失
  4. Pudding cover dialog

可能会有的疑问:

  • Pudding使用的是WindowManager 难道不需要申请权限吗?

    • Pudding使用WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL的层级低于系统级层级TYPE_SYSTEM_ALERT也就是在2000之下,是不需要申请权限的。
  • 不同的Activity对应的WindowManager是否相同

    • 不同的window,不同的WindowManager,相同的WindowManagerGlobal(最终实现view的添加、删除、更新)
  • 不同的WindowManager为什么可以移除对方的View

    • 因为所有的Activity共同只有一个WindowManagerGlobal(其内部持有所有添加的View的集合引用)
  • 如何去维护一个Pudding队列

    • 用一个Map<string,pudding>
    • 什么时间 去clear这个map (●゚ω゚●)挠头? when activity destory clean the key which is activity toString()
MIT License Copyright (c) 2019 zhaocy 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.

简介

Android 代替 Toast/SnackBar 新方式,使用 WindowManager 无需申请权限 展开 收起
Kotlin
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Kotlin
1
https://gitee.com/love_yaoyao/PuddingAlert.git
git@gitee.com:love_yaoyao/PuddingAlert.git
love_yaoyao
PuddingAlert
PuddingAlert
master

搜索帮助