mirror of
https://gitee.com/openharmony/global_resource_management
synced 2024-10-06 21:43:49 +00:00
commit
30080b4ef6
@ -387,7 +387,7 @@ bool HapManager::AddResource(const std::string &path, const std::vector<std::str
|
||||
RESMGR_HILOGI(RESMGR_TAG, "the overlay for %{public}s already been loaded", path.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<HapResource>> tmpHapResources;
|
||||
std::vector<std::string> tempOverlays;
|
||||
bool isPathLoad = false;
|
||||
std::shared_ptr<HapResource> hapResource = HapResourceManager::GetInstance()->getHapResource(path);
|
||||
@ -399,13 +399,12 @@ bool HapManager::AddResource(const std::string &path, const std::vector<std::str
|
||||
for (const std::string& overlayPath : overlayPaths) {
|
||||
std::shared_ptr<HapResource> overlayResource = HapResourceManager::GetInstance()->getHapResource(overlayPath);
|
||||
if (overlayResource) {
|
||||
hapResources_.push_back(overlayResource);
|
||||
overlayResource->UpdateDarkConfig(this->resConfig_);
|
||||
tmpHapResources[overlayPath] = overlayResource;
|
||||
} else {
|
||||
tempOverlays.push_back(overlayPath);
|
||||
tmpHapResources[overlayPath] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<HapResource>> result;
|
||||
if (!isPathLoad || tempOverlays.size() > 0) {
|
||||
result = HapResource::LoadOverlays(path, tempOverlays, resConfig_, isSystem_);
|
||||
@ -413,21 +412,19 @@ bool HapManager::AddResource(const std::string &path, const std::vector<std::str
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPathLoad && result.find(path) != result.end()) {
|
||||
std::shared_ptr<HapResource> pResource =
|
||||
HapResourceManager::GetInstance()->PutAndGetResource(path, result[path]);
|
||||
hapResources_.push_back(pResource);
|
||||
result[path]->UpdateDarkConfig(this->resConfig_);
|
||||
}
|
||||
|
||||
for (auto iter = result.begin(); iter != result.end(); iter++) {
|
||||
if (iter->second->IsOverlayResource()) {
|
||||
std::shared_ptr<HapResource> pResource =
|
||||
HapResourceManager::GetInstance()->PutAndGetResource(iter->first, iter->second);
|
||||
hapResources_.push_back(pResource);
|
||||
iter->second->UpdateDarkConfig(this->resConfig_);
|
||||
for (auto iter = overlayPaths.rbegin(); iter != overlayPaths.rend(); iter++) {
|
||||
std::shared_ptr<HapResource> pResource = tmpHapResources[*iter];
|
||||
if (pResource == nullptr) {
|
||||
pResource = HapResourceManager::GetInstance()->PutAndGetResource(*iter, result[*iter]);
|
||||
}
|
||||
hapResources_.push_back(pResource);
|
||||
pResource->UpdateDarkConfig(this->resConfig_);
|
||||
}
|
||||
loadedHapPaths_[path] = overlayPaths;
|
||||
return true;
|
||||
|
@ -539,7 +539,7 @@ void HapResource::IsAppDarkRes(const std::shared_ptr<HapResource::ValueUnderQual
|
||||
|
||||
void HapResource::UpdateDarkConfig(std::shared_ptr<ResConfigImpl> &defaultConfig)
|
||||
{
|
||||
if (hasDarkRes_) {
|
||||
if (hasDarkRes_ && defaultConfig != nullptr) {
|
||||
defaultConfig->SetAppDarkRes(hasDarkRes_);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user