{
public:
AlarmWidget();
+ virtual ~AlarmWidget() override;
private:
virtual void onCreate(bundle *content) override;
void onPickReply(app_control_h request, app_control_h reply, app_control_result_e result);
void onCreateReply(app_control_h request, app_control_h reply, app_control_result_e result);
+ void onReply(const std::string &id);
void setAlarm(Common::Model::Alarm *alarm);
Evas_Object *m_Layout;
#include "Common/Model/Alarm.h"
#include "Common/Model/AlarmConsumer.h"
#include "Ui/Window.h"
+#include "Utils/Bundle.h"
#include "Utils/Callback.h"
-#include "Utils/Logger.h"
#include "CommonPath.h"
#include "WidgetLayout.h"
using namespace Common;
using namespace Common::Model;
+#define ALARM_ID_KEY "alarm_id"
#define TIME_SIZE 40
#define APP_CONTROL_MIME_ALARM "application/vnd.tizen.alarm"
{
}
+AlarmWidget::~AlarmWidget()
+{
+ delete m_Alarm;
+}
+
void AlarmWidget::onCreate(bundle *content)
{
elm_theme_extension_add(nullptr, App::getResourcePath(PATH_ALARM_CHECK_STYLE).c_str());
+ if (content) {
+ if (int alarmId = Utils::Bundle(content).getInt(ALARM_ID_KEY)) {
+ AlarmConsumer::getInstance().getDataItem(alarmId, [this](AlarmConsumer::DataList dataList) {
+ setAlarm(static_cast<Alarm *>(dataList.front()));
+ });
+ return;
+ }
+ }
+
updateEmptyState();
}
void AlarmWidget::onPickReply(app_control_h request, app_control_h reply, app_control_result_e result)
{
- std::string id = App::getStringExtraData(reply, APP_CONTROL_DATA_SELECTED);
- AlarmConsumer::getInstance().getDataItem(atoi(id.c_str()), [this](AlarmConsumer::DataList dataList) {
- setAlarm(static_cast<Alarm *>(dataList.front()));
- updateEmptyState();
- });
+ onReply(App::getStringExtraData(reply, APP_CONTROL_DATA_SELECTED));
}
void AlarmWidget::onCreateReply(app_control_h request, app_control_h reply, app_control_result_e result)
{
- std::string id = App::getStringExtraData(reply, APP_CONTROL_DATA_ID);
+ onReply(App::getStringExtraData(reply, APP_CONTROL_DATA_ID));
+}
+
+void AlarmWidget::onReply(const std::string &id)
+{
AlarmConsumer::getInstance().getDataItem(atoi(id.c_str()), [this](AlarmConsumer::DataList dataList) {
setAlarm(static_cast<Alarm *>(dataList.front()));
- updateEmptyState();
+
+ Utils::Bundle bundle;
+ bundle.addInt(ALARM_ID_KEY, m_Alarm->getId());
+ saveContent(bundle.getBundle());
});
}
delete widget->m_Alarm;
widget->m_Alarm = nullptr;
widget->updateEmptyState();
+
+ Utils::Bundle bundle;
+ bundle.addInt(ALARM_ID_KEY, 0);
+ widget->saveContent(bundle.getBundle());
}, this);
}, this };
m_Alarm->onUpdated() += { [this](int changes) {
updateContentLayout(changes);
}, this };
+
+ updateEmptyState();
}