Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Support refreshFinish for eagle (#2416)
Browse files Browse the repository at this point in the history
  • Loading branch information
YorkShen authored and jianhan-he committed May 9, 2019
1 parent c49751b commit e9d4ba1
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions weex_core/Source/core/bridge/platform/core_side_in_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e9d4ba1

Please sign in to comment.