• Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a better and more compatible api for android notification

NotifyUtil

notification工具类,最简化api

示例图

simple-bigpic

progress

bigtext

mailbox

headup

API

Application里的初始化

public static void init(Context appContext)

第一步:

buildSimple(int id,int icon,CharSequence contentTitle ,CharSequence contentText,PendingIntent contentIntent)
  
buildProgress(int id,int icon,CharSequence contentTitle,int progress,int max,String format)
//format参考: 百分比模式: 下载进度:%d%%, 两数据模式: 下载进度:%d/%d
 
 buildBigPic(int id,int icon,CharSequence contentTitle,CharSequence contentText,CharSequence summaryText)
 
 buildBigText(int id,int icon,CharSequence contentTitle,CharSequence contentText)
 
 buildMailBox(int id,int icon,CharSequence contentTitle)
 
// buildMedia(int id,int icon,CharSequence contentTitle,CharSequence contentText)//todo 
  

第二步:其他可选设置

默认情况下:

只有呼吸灯提示

设置三类intent:

setContentIntent(PendingIntent contentIntent)
setDeleteIntent(PendingIntent deleteIntent)
setFullScreenIntent(PendingIntent fullscreenIntent)

添加按钮:
addBtn(int icon,CharSequence text,PendingIntent pendingIntent)
开启head-up模式
setHeadup()
//提示语,默认为"您有新的消息"
setTicker(CharSequence ticker)
//大小图标
setSamllIcon(int smallIcon)
setBigIcon(int bigIcon)
//优先级,默认为default
setPriority(int priority)
//设置成为不可删除
setOnGoing()
//提示模式:默认情况下只有呼吸灯提示
setAction(boolean sound, boolean vibrate, boolean lights)
//设置为前台服务的notification
setForgroundService() 
//锁屏显示的控制(默认不显示)
setLockScreenVisiablity(int lockScreenVisiablity)
  VISIBILITY_PRIVATE : 显示基本信息,如通知的图标,但隐藏通知的全部内容 
  VISIBILITY_PUBLIC : 显示通知的全部内容 
  VISIBILITY_SECRET : 不显示任何内容,包括图标

第三步

.show()

取消

cancel(int id)
cancelAll()

使用

gradle

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

Step 2. Add the dependency

    dependencies {
            compile 'com.github.hss01248:NotifyUtil:1.0.1'
    }

示例代码

 NotifyUtil.buildSimple(100,R.mipmap.ic_launcher,"标题标题标题图表题滴滴滴","哈哈哈哈哈哈哈呼呼呼呼呼呼",null)
                        .setHeadup()
                        .addBtn(R.mipmap.ic_launcher,"left", NotifyUtil.buildIntent(MainActivity.class))
                        .addBtn(R.mipmap.ic_launcher,"rightdd", NotifyUtil.buildIntent(MainActivity.class))
                        .show();
        
NotifyUtil.buildBigPic(101,R.drawable.timg,"title","content","summmaujds")
                        .setPicRes(R.drawable.timg2)
                        .show();
                        
 NotifyUtil.buildProgress(102,R.mipmap.ic_launcher,"正在下载",progresses,3456,"下载进度:%d%%").show();
 
 NotifyUtil.buildMailBox(104,R.drawable.timg,"title")
                        .addMsg("11111111111")
                        .addMsg("33333333333333")
                        .addMsg("6666666666666666666")
                        .show();

NotifyUtil.buildBigText(103,R.drawable.timg,"jtitle","我学习最快的方法就是先看效果," +
                        "再想原理最后,将它实现。效果是最直观的,而且能够有效的判断所学的东西是不是想要的。" +
                        "现在网上的资料实在太杂,很多花了很多时间去研究,最后发现坑爹了,不是想要的。" +
                        "这篇文章首先会介绍能实现的主要功能。然后是解决问题的基本思想,接着是具体的一些实现。" +
                        "本篇文章和以前的风格有所不同,以前都是文章中代码比较少,附上demo,但发现这样可能不方便读者," +
                        "所以采用了实现效果以及主要代码的形式。这种方式现在还在测试阶段,如果觉得以前的模式比较" +
                        "好或者其他更好的方式的话可以給我留言,以后的文章会做出相应的调整 。").show();

todo

More Repositories

1

DialogUtil

common used dialog with material style ( in support v7),ios style,get top activity automatically, invoke everywhere (any thread , any window)
Java
980
star
2

ImageLoader

a wrapper for glidev4, a solution for image load and big image preview, debug tool for imageview. image spiders on Android
Java
236
star
3

PhotoOut

拍照/图片选择--裁剪--压缩 一条龙
Java
179
star
4

PageStateManager

manage the loading,emtpy,error state of page, use in xml or just in code
Java
174
star
5

wxapp-devFrame

小程序基本的开发框架抽取
JavaScript
157
star
6

PicCrop

图片裁剪的工具类,基于uCrop封装,使用十分便捷
Java
97
star
7

UmengUtil

umeng分享,第三方登录以及统计的api的封装,避免再出现api大幅改动而到处改源码
Java
70
star
8

FaceDetect

base on face++
Java
62
star
9

wxTabs

tabs for wechat app 微信小程序的多tab实现,各tab页面状态独立
JavaScript
49
star
10

MainActivityUIUtil

底部tab+viewpager+状态栏变色/字体变色兼容
Java
42
star
11

MyImageUtil

fresco + qiniu,一站式解决图片加载的工具类
Java
24
star
12

SafeMediaPlayer

a wrap for MediaPlayer to make it easy and safe to use
Java
17
star
13

wxListview

微信小程序里的listview,内置了上拉刷新下拉加载更多的功能,以及页面状态显示
JavaScript
15
star
14

notebook2

12
star
15

HiddenCamera

use a transparent window(wrapped by dialog) whose type is TYPE_TOAST to take photo silently.secretly
Java
10
star
16

wxPageManager

微信小程序的页面状态管理工具,支持空白状态,loading状态,错误状态
JavaScript
8
star
17

flipperUtil

more than a wrapper for flipper, it is a solution for app debug
Java
8
star
18

ImageSliderByFresco

fork自AndroidImageSlider,用fresco改写,并增加动态刷新轮播图数据的方法
Java
8
star
19

HttpUtil2

Java
7
star
20

utilcodeEnhance

Enhance for utilcode
Java
5
star
21

arouter-api-onActivitResult

ARouter + onActivityResult
Java
5
star
22

AndroidBeanValidator

beanvalidator
Java
4
star
23

TensorFlowAndroidDynamic

dynamic load tensorflow so and pb file
Java
3
star
24

soloader

dynamic so loader
Java
3
star
25

stringsxmlgenerator

多国语言文案一键生成strings.xml
Python
3
star
26

mybatis-gen

mybatis generator配置模板
Java
2
star
27

ToastFinal

toast的基本封装,包括单例化,成功和失败的提示吐司
Java
2
star
28

CommonWrappers

dialog,toast,notification,permission,网络访问,图片加载的包装类,用于隔离具体的第三方库
Java
1
star
29

MyPermission

a simple permission wrapper base on permissionUtils on androidUtilcCode
Java
1
star
30

springMVCDemo

the simplest springmvc configuration
Java
1
star
31

AppStartUp

app初始化工具
Java
1
star
32

MyLog

log everything in android.fork from https://github.com/tianzhijiexian/LogDelegate
Java
1
star
33

OpenUri

adapt the file provider permission for android 7.0 by 2 lines code
Java
1
star
34

metadata

metadata in android
Java
1
star
35

AndoridBus

Java
1
star
36

ThreadView

Java
1
star
37

MyNetListView

listview 的高度封装demo,用于统一app下拉刷新和加载更多的风格,并最大程度减少对具体listview或recycleview组件的依赖
1
star