Android切面编程实现(AOP)

AOP

Android切面编程实现
GitHub仓库地址

引入

gradle

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

//如果使用aop,项目的build.gradle添加以下代码
dependencies {
    
    
    classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
}
//如果使用aop,app的build.gradle添加插件android-aspectjx
apply plugin: 'android-aspectjx'
// AOP 配置
// AspectJX默认会处理所有的二进制代码文件和库,为了提升编译效率及规避部分第三方库出现的编译兼容性问题,
// AspectJX提供include,exclude命令来过滤需要处理的文件及排除某些文件(包括class文件及jar文件)。
aspectjx {
    
    
     //只导入需要AspectJX处理的包com.zhangteng.aop必须添加
    include 'com.zhangteng.aop', '应用包名'
}

implementation 'com.github.DL-ZhangTeng:AOP:2.0.0'

aop工具包(com/zhangteng/aop)

工具包名/类名 描述
TimeLog 在需要打印耗时时间的方法添加此注解
TimeLogAspect 耗时时间方法切入点处理逻辑
CheckNet 在需要网络检测的方法添加此注解
CheckNetAspect 网络检测方法切入点处理逻辑
Permissions 在需要权限申请的方法添加此注解
PermissionsAspect 权限申请方法切入点处理逻辑
SingleClick 在需要防重复点击的方法添加此注解
SingleClickAspect 防重复点击方法切入点处理逻辑

混淆

-keep public class com.zhangteng.**.*{ *; }

历史版本

版本 更新 更新时间
v2.0.0 从BaseLibrary分离出AOP 2022/9/14 at 22:36

赞赏

如果您喜欢AOP,或感觉AOP帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢

联系我

邮箱:[email protected]/[email protected]

License

Copyright © [2020] [Swing]

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.

猜你喜欢

转载自blog.csdn.net/duoluo9/article/details/126879386
今日推荐