SimpleTouch: event distribution can be so clear

The library has been open to github, address github.com/AlexMahao/S...

Android library for listening event distribution process, two lines of code in the distribution process to listen for events during the run. Automatically print distribution process, and to provide a view view.

function display

Console log output

View a chart

View JSON format

Brief introduction

SimpleTouchIn order to solve the problem of the birth event distribution, the library can print the complete event distribution process at run time.

  • Monitor Viewthe dispatchTouchEvent, onTouchEvent, onInterceptTouchEvent.
  • Print dynamic event runs during the distribution process.
  • Each complete record of the event distribution jsonin the form of written documents.
  • De-emphasis function, the same movewill automatically filter events.
  • Provide no-opversion, use can be distinguished debugand release.
  • Provide different display modes

use

Add dependent

In the project appunder the build.gradleadded dependencies

debugApi 'com.spearbothy:simple-touch:1.0.7'
releaseApi 'com.spearbothy:simple-touch-no-op:1.0.7'
复制代码

initialization

In the project Application's onCreate()initialization method is called inTouch.inject(this);

Touch.init(this, new Config().setSimple(false));

复制代码

ConfigObject provides a number of configuration options

public class Config {

    // 输出的日志以极简模式输出
    private boolean isSimple = true;
    // 是否延迟打印日志,延迟打印日志会在触摸事件结束之后打印,并且具有去重功能
    private boolean isDelay = true;
    // 是否保留重复的,默认不保留
    private boolean isRepeat = false;
    // 是否写入到文件
    private boolean isPrint2File = true;
    // 是否处理,不处理则不会监听任何方法,任何功能都无法生效
    private boolean isProcess = true;
}

复制代码

Injection proxy class (for monitoring event distribution)

In Activitythe onCreate()the super.onCreate(savedInstanceState);call before.

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        Touch.inject(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mRootView = (LinearLayout) findViewById(R.id.root);
    }
复制代码

use

After the compilation is complete, open the app, began to touch it! ! ! Each finger off the touch at the intervals greater than 1s, for each object is to distinguish touch, did not expect a suitable temporary determination condition.

View flowchart

Pull down the notifications can be seen in the entrance SimpleTouch

Remark

  • Providing a no-opversion that contains initialization and air injection method realized in order to achieve debugand releaseuse different versions that releasedo not contain any initialization logic and injection.
  • When injected a little time-consuming, if the page is too complex, the page will have a feeling of Caton.

Tripartite library reference or draw

  • com.android.support:appcompat-v7
  • com.google.dexmaker:dexmaker
  • com.alibaba:fastjson
  • com.noober.background:core
  • com.yuyh.json:jsonviewer

on

You have any questions by issueor sent to mail in the form[email protected]

Reproduced in: https: //juejin.im/post/5cf62ab9518825789e031b24

Guess you like

Origin blog.csdn.net/weixin_33967071/article/details/91431125