This is an automated email from the ASF dual-hosted git repository. jianhan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push: new e9d4ba1 Support refreshFinish for eagle (#2416) e9d4ba1 is described below commit e9d4ba140d81df71d3a23f445e1d7a3c6a39afb8 Author: YorkShen <shenyua...@gmail.com> AuthorDate: Thu May 9 11:44:17 2019 +0800 Support refreshFinish for eagle (#2416) --- .../core/bridge/platform/core_side_in_platform.cpp | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/weex_core/Source/core/bridge/platform/core_side_in_platform.cpp b/weex_core/Source/core/bridge/platform/core_side_in_platform.cpp index e980845..c71589a 100644 --- a/weex_core/Source/core/bridge/platform/core_side_in_platform.cpp +++ b/weex_core/Source/core/bridge/platform/core_side_in_platform.cpp @@ -30,6 +30,10 @@ #include "core/render/page/render_page.h" #include "core/bridge/eagle_bridge.h" #include "third_party/json11/json11.hpp" +#ifdef OS_ANDROID +#include <android/utils/params_utils.h> +#include <wson/wson.h> +#endif namespace WeexCore { @@ -322,6 +326,49 @@ int CoreSideInPlatform::RefreshInstance( params[1]->value.string->length); auto handler = EagleBridge::GetInstance()->data_render_handler(); if (handler && handler->RefreshPage(instanceId, init_data)) { + std::vector<VALUE_WITH_TYPE*> msg; + + VALUE_WITH_TYPE* event = getValueWithTypePtr(); + event->type = ParamsType::BYTEARRAY; + auto buffer = wson_buffer_new(); + wson_push_type_uint8_string( + buffer, reinterpret_cast<const uint8_t*>(instanceId), strlen(instanceId)); + event->value.byteArray = genWeexByteArray( + static_cast<const char*>(buffer->data), buffer->position); + wson_buffer_free(buffer); + msg.push_back(event); + + // args -> { method: 'fireEvent', args: [ref, "nodeEvent", args , domChanges, {params: [ {"templateId": templateId, "componentId": id, "type": type, "params" : [...]} ]}] } + VALUE_WITH_TYPE* args = getValueWithTypePtr(); + args->type = ParamsType::JSONSTRING; + json11::Json final_json = json11::Json::array{ + json11::Json::object{ + {"method", "fireEvent"}, + {"args", + json11::Json::array{ + "", "refresh", json11::Json::array{}, "", + json11::Json::object{ + {"params", + json11::Json::array{ + json11::Json::object{ + {"data", init_data} + } + }} + } + }} + } + }; + + auto final_json_str = final_json.dump().c_str(); + auto utf16_key = weex::base::to_utf16(const_cast<char*>(final_json_str), + strlen(final_json_str)); + args->value.string = genWeexString( + reinterpret_cast<const uint16_t*>(utf16_key.c_str()), utf16_key.size()); + msg.push_back(args); + + WeexCore::WeexCoreManager::Instance()->script_bridge()->script_side()->ExecJS( + instanceId, "", "callJS", msg); + freeParams(msg); return true; } return ExecJS(instanceId, nameSpace, func, params);