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
SimpleTouch
In order to solve the problem of the birth event distribution, the library can print the complete event distribution process at run time.
- Monitor
View
thedispatchTouchEvent
,onTouchEvent
,onInterceptTouchEvent
. - Print dynamic event runs during the distribution process.
- Each complete record of the event distribution
json
in the form of written documents. - De-emphasis function, the same
move
will automatically filter events. - Provide
no-op
version, use can be distinguisheddebug
andrelease
. - Provide different display modes
use
Add dependent
In the project app
under the build.gradle
added 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));
复制代码
Config
Object 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 Activity
the 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-op
version that contains initialization and air injection method realized in order to achievedebug
andrelease
use different versions thatrelease
do 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 issue
or sent to mail in the form[email protected]
Reproduced in: https: //juejin.im/post/5cf62ab9518825789e031b24