用代码画流程图和时序图快餐教程(4) - mermaid时序图

mermaid时序图

时序图声明

mermaid支持多种图,所以要先通过sequenceDiagram

sequenceDiagram

participant

mermaid的participant不支持直接声明颜色,只能声明个名字了

sequenceDiagram
participant Activity
participant ContextWrapper

消息要用双箭头

按照PlantUML的习惯写“->”是不行的,这样会没有箭头。如果要往箭头,还需要再加一个">",变成"->>".

sequenceDiagram
    Activity ->> ContextWrapper : registerReceiver()
    ContextWrapper ->> ContextImpl : registerReceiver()

完整例子

sequenceDiagram
    Activity ->> ContextWrapper : registerReceiver()
    ContextWrapper ->> ContextImpl : registerReceiver()
    ContextImpl ->> LoadedApk : getReceiverDispatcher()
    LoadedApk ->> ActivityManagerProxy : registerReceiver()
    ActivityManagerProxy ->> ActivityManagerService : registerReceiver()

    Activity ->> ContextWrapper : sendBroadcast()
    ContextWrapper ->> ContextImpl : sendBroadcast()
    ContextImpl ->> ActivityManagerService: broadcastIntent()
    ActivityManagerService ->> ActivityManagerService : broadcastIntentLocked()
    ActivityManagerService ->> ActivityManagerService : collectReceiverComponents()
    ActivityManagerService ->> ActivityManagerService : scheduleBroadcastsLocked()
    ActivityManagerService ->> ActivityManagerService : processNextBroadcast()
    ActivityManagerService ->> ActivityManagerService : deliverToRegisteredReceiverLocked()
    ActivityManagerService ->> ActivityManagerService : performReceiveLocked()
    ActivityManagerService ->> ApplicationThreadProxy : scheduleRegisteredReceiver()
    ApplicationThreadProxy ->> InnerReceiver : performReceive()
    InnerReceiver ->> ReceiverDispatcher : performReceive()
    ReceiverDispatcher ->> BroadcastReceiver : onReceive()

    Activity ->> ContextWrapper : sendOrderedBroadcast()
    ContextWrapper ->> ContextImpl : sendOrderedBroadcast()
    ContextImpl ->> ActivityManagerService: broadcastIntent()

生成的图形如下:
用代码画流程图和时序图快餐教程(4) - mermaid时序图_第1张图片

你可能感兴趣的:(用代码画流程图和时序图快餐教程(4) - mermaid时序图)