Git Product home page Git Product logo

xerath's Introduction

简体中文 | English |

Xerath

Xerath 是一个通过 [自定义注解]+ASM + Gradle Transform API 实现的一套功能强大,方便开发,并且能够有效减少重复代码的Android Aop 框架。
旨在编译器进行全局性的修改,来完成一些诸如方法耗时统计,异常收集,拦截,动态代理等特殊需求。
核心**基于AOP编程,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程。
本项目为AOP**在Android上的运用与实战,功能部分对标基于AspectJ的开源项目AopArms

引入方式

待上传到Maven,目前可以clone项目然后主动依赖

基本使用

1.统计方法耗时
在目标方法上增加@CalculateTime注解

    @CalculateTime
    public static void CalculateTimeMethod() {
        //do something
    }

2.限制方法频繁调用
在目标方法上增加@Xerath_LimitCall(time = 1000L)注解,其中time为频繁调用的时间阈值

    @Xerath_LimitCall(time = 1000L)
    public static void doubleClick() {
        //do something
    }

3.try-catch异常捕获
在目标方法上增加@TryCatch注解

    @TryCatch
    public static void tryCatchMethod() {
        int a = 1 / 0;
    }

4.方法入参和返回值统计
在目标方法上增加@Xerath_CollectParams

    @Xerath_CollectParams
    public static String testParams(boolean boolParam, byte byteParam, char charParam, short shortParam, int intParam, long longParam,
                                    float floatParam, double doubleParam, String stringParam, int[] intArrParam, JSONObject json) {
        String result = boolParam + " " + byteParam + " " + charParam + " " + shortParam + " " + intParam + " " +
                longParam + " " + floatParam + " " + doubleParam + " " + stringParam + " " + intArrParam.length + json.toString();
        return result;
    }

5 .弹出Toast
在目标方法上增加@Xerath_PopToast注解,其中str为需要显示Toast的内容

    @Xerath_PopToast(str = "测试Toast")
    public static void popToast() {
        //do something
    }

功能列表(补充中)


参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

鸣谢

License

Copyright 2021, Jiang Zhengnan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

xerath's People

Contributors

jiangzhengnan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.