2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "notification-ex/image_item.h"
20 #include "notification-ex/image_item_implementation.h"
21 #include "notification-ex/factory_manager.h"
22 #include "notification-ex/exception.h"
28 #define LOG_TAG "NOTIFICATION_EX"
29 #define IMAGE_PATH_KEY "__IMAGE_PATH_KEY__"
31 namespace notification {
34 ImageItem::ImageItem(std::string imagePath,
35 std::shared_ptr<AbstractAction> action)
36 : AbstractItem(action), impl_(new Impl(this, imagePath)) {
39 ImageItem::ImageItem(std::string id, std::string imagePath,
40 std::shared_ptr<AbstractAction> action)
41 : AbstractItem(id, action), impl_(new Impl(this, imagePath)) {
44 ImageItem::Impl::Impl(ImageItem* parent, std::string imagePath)
45 : parent_(parent), imagePath_(imagePath) {
46 LOGI("ImageItem impl created");
49 int ImageItem::GetType() const {
50 return AbstractItem::Image;
53 Bundle ImageItem::Serialize() const {
55 b = AbstractItem::Serialize();
56 b.Add(IMAGE_PATH_KEY, impl_->imagePath_);
61 void ImageItem::Deserialize(Bundle b) {
62 AbstractItem::Deserialize(b);
64 impl_->imagePath_ = b.GetString(IMAGE_PATH_KEY);
67 AbstractItem& ImageItem::FindByID(std::string id) {
71 return FactoryManager::GetInst().GetNullItem();
74 std::string ImageItem::GetImagePath() const {
75 return impl_->imagePath_;
78 ImageItem::~ImageItem() = default;
79 ImageItem::Impl::~Impl() = default;
83 } // namespace notification