• 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'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    aop工具包(com/zhangteng/aop)

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

    混淆

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

    历史版本

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

    赞赏

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

    联系我

    邮箱:763263311@qq.com/ztxiaoran@foxmail.com

    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.

  • 相关阅读:
    Spring中事务失效的原因
    2022 年 JavaScript 开发工具的生态,别再用过时的框架了
    前端Vue返回顶部[功能]和底部四个角[样式](代源码和详图)
    腾讯待办停止运营,怎么继续提醒事情呢?
    LeetCode 每日一题——655. 输出二叉树
    大数据必学Java基础(五十七):Set接口讲解
    布隆过滤器原理及实现
    获取系统参数System.getProperties()与配置文件参数@Value(“${key}“)
    从Oracle迁移数据到Hadoop
    五分钟带你了解Python基础知识【精华】
  • 原文地址:https://blog.csdn.net/duoluo9/article/details/126879386