dueros / dcs-sdk-java

Apache License 2.0
338 stars 120 forks source link

PayloadConfig添加RenderCardPayload #55

Open rxnh8255 opened 6 years ago

rxnh8255 commented 6 years ago

源代码里面这个地方没有添加RenderCardPayload, 所以在

deviceModuleFactory.getScreenDeviceModule().addRenderListener(new 
  ScreenDeviceModule.IRenderListener() {
            @Override
            public void onRenderDirective(Directive directive) {
                Log.i(TAG, "传回的screen数据: "+directive.rawMessage);
                if(directive.getPayload() instanceof RenderCardPayload){
                    RenderCardPayload rcp =  (RenderCardPayload)directive.getPayload();
                    Log.i(TAG, "rcpType: "+rcp.type);
                    if(rcp.type == RenderCardPayload.Type.StandardCard){
                        //do something
                    }
                }
            }
        });

会报错 在com.baidu.duer.dcs.framework.message.PayloadConfig里面添加代码

private PayloadConfig() {
        payloadClass = new HashMap<>();

        // AudioInputImpl
        ...
        // Screen
        namespace = com.baidu.duer.dcs.devicemodule.screen.ApiConstants.NAMESPACE;
        name = com.baidu.duer.dcs.devicemodule.screen.ApiConstants.Directives.HtmlView.NAME;
        insertPayload(namespace, name, HtmlPayload.class);
        name = com.baidu.duer.dcs.devicemodule.screen.ApiConstants.Directives.RenderVoiceInputText.NAME;
        insertPayload(namespace, name, RenderVoiceInputTextPayload.class);
        //添加的代码
        name = com.baidu.duer.dcs.devicemodule.screen.ApiConstants.Directives.RenderCard.NAME;
        insertPayload(namespace, name, RenderCardPayload.class);
    }