!39094 修改主动发起拖拽的capi接口

Merge pull request !39094 from Zhang Jinyu/ptrnull
This commit is contained in:
openharmony_ci 2024-07-30 08:00:50 +00:00 committed by Gitee
commit aad6a4075a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 20 additions and 8 deletions

View File

@ -35,11 +35,6 @@ static void DragActionConvert(
{
internalDragAction->pointer = dragAction->pointerId;
internalDragAction->size = dragAction->size;
auto* pixelMapTemp = reinterpret_cast<std::shared_ptr<void*>*>(dragAction->pixelmapArray);
for (int index = 0; index < dragAction->size; index++) {
auto pixelMap = PixelMap::CreatePixelMap(&pixelMapTemp[index]);
internalDragAction->pixelMapList.push_back(pixelMap);
}
internalDragAction->previewOption.isScaleEnabled = dragAction->dragPreviewOption.isScaleEnabled;
if (!internalDragAction->previewOption.isScaleEnabled) {
internalDragAction->previewOption.isDefaultShadowEnabled = dragAction->dragPreviewOption.isDefaultShadowEnabled;
@ -88,6 +83,11 @@ ArkUI_Int32 StartDrag(ArkUIDragAction* dragAction)
CHECK_NULL_VOID(listener);
listener(&outInfo, userData);
};
auto* pixelMapTemp = reinterpret_cast<std::shared_ptr<void*>*>(dragAction->pixelmapArray);
for (int index = 0; index < dragAction->size; index++) {
auto pixelMap = PixelMap::CreatePixelMap(&pixelMapTemp[index]);
internalDragAction->pixelMapList.push_back(pixelMap);
}
internalDragAction->callback = callbacks;
DragActionConvert(dragAction, internalDragAction);
OHOS::Ace::NG::DragDropFuncWrapper::StartDragAction(internalDragAction);

View File

@ -178,14 +178,17 @@ int32_t OH_ArkUI_DragAction_SetPixelMaps(ArkUI_DragAction* dragAction, OH_Pixelm
if (!dragActions) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
std::vector<std::shared_ptr<OHOS::Media::PixelMap>> pixelMapList;
int32_t count = 0;
for (int32_t index = 0; index < size; index++) {
if (!pixelmapArray[index]) {
continue;
}
pixelMapList.push_back(pixelmapArray[index]->GetInnerPixelmap());
count++;
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelMapList.data());
if (count < size || size < 0) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelmapArray);
dragActions->size = size;
return ARKUI_ERROR_CODE_NO_ERROR;
}
@ -297,6 +300,15 @@ int32_t OH_ArkUI_StartDrag(ArkUI_DragAction* dragAction)
if (!dragActions || !impl) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
std::vector<std::shared_ptr<OHOS::Media::PixelMap>> pixelMapList;
auto pixelmapArray = reinterpret_cast<OH_PixelmapNative**>(dragActions->pixelmapArray);
for (int32_t index = 0; index < dragActions->size; index++) {
if (!pixelmapArray[index]) {
continue;
}
pixelMapList.push_back(pixelmapArray[index]->GetInnerPixelmap());
}
dragActions->pixelmapArray = reinterpret_cast<void**>(pixelMapList.data());
impl->getDragAdapterAPI()->startDrag(dragActions);
return ARKUI_ERROR_CODE_NO_ERROR;
}