• KeyEvent


    http://blog.csdn.net/elfylin/article/details/8008763

    一. 接口
    KeyEvent.Callback和View.OnKeyListener


    二. 流程
    a.Activity.dispatchKeyEvent
    a.1.win.superDispatchKeyEvent(win=getWindow)
    Window.superDispatchKeyEvent->PhoneWindow.superDispatchKeyEvent
    a.2mDecor.superDispatchKeyEvent (mDecor=FrameLayout)
    PhoneWindow.mDecor.superDispatchKeyEvent
    a.3view. dispatchKeyEvent (Window.dispatchKeyEvent)
    View.dispatchKeyEvent(View=mDecor)
    b.event.dispatch
    mOnKeyListener.onKey


    三.Event
    a. who call onKeyDown?
    b. who call dispatchKeyevent
    c. dispatchKeyEvent的实现在PhoneWindow.dispatchKeyEvent
    PhoneWindows重载了View的dispatchKeyEvent和KeyEventCallback的OnKeyXX
    首先调用dispatchKeyEvent,如果返回false才调用onKeyXX
    在其父类View的dispatchKeyEvent,会调用KeyListener。


    四.优先级
    1.当一个Activity中收到事件,首先查看自己的decor是否有焦点,
    1.1如果有调用它的dispatchKeyEvent,(即调用它的keylistener);
    1.2否则,获取焦点窗口,调用焦点窗口的dispatchKeyEvent;
    2.如果上面都为false,就调用自己的onkeydown和onkeyup事件。


    五 入口
    HelloworldActivity.onKeyDown(int, KeyEvent) line: 25
    KeyEvent.dispatch(KeyEvent$Callback, KeyEvent$DispatcherState, Object) line: 2555
    HelloworldActivity(Activity).dispatchKeyEvent(KeyEvent) line: 2358
    HelloworldActivity.dispatchKeyEvent(KeyEvent) line: 29
    PhoneWindow$DecorView.dispatchKeyEvent(KeyEvent) line: 1806
    ViewRootImpl.deliverKeyEventPostIme(KeyEvent, boolean) line: 3328
    ViewRootImpl.handleFinishedEvent(int, boolean) line: 3301
    ViewRootImpl.handleMessage(Message) line: 2461 
    ViewRootImpl(Handler).dispatchMessage(Message) line: 99
    Looper.loop() line: 137
    ActivityThread.main(String[]) line: 4444
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
    Method.invoke(Object, Object...) line: 511
    ZygoteInit$MethodAndArgsCaller.run() line: 787 
    ZygoteInit.main(String[]) line: 554
    NativeStart.main(String[]) line: not available [native method]

  • 相关阅读:
    json编解码
    Grok 正则捕获
    logstash date插件介绍
    logstash 字段类型转换后 需要刷新
    logstash 防止实际处理时间跟事件产生时间略有偏差
    导入旧数据需要 使用date插件
    nginx和tomcat的响应时间
    解决kibana 4 关于响应时间的问题
    go 可以开发桌面应用
    windows下go语言环境
  • 原文地址:https://www.cnblogs.com/daishuguang/p/3718024.html
Copyright © 2020-2023  润新知