free(caller);
} else {
__alertData = std::make_shared<CalAlertData>(request);
+ __model = std::make_shared<CalAlertModel>(__alertData);
if (__alertData->getCount()) {
mode = CalAlertModel::isDeviceLocked() ? CALALERT_VIEW :
CALALERT_ACTIVE_NOTIFICATION;
WDEBUG("len(%d)", len);
if (ids && len > 0) {
// calendar-service
+ int recordIndex = -1;
for (int i = 0; i < len; i++) {
- int recordIndex = atoi(ids[i]);
+ recordIndex = atoi(ids[i]);
__addRecord(recordIndex, false);
WDEBUG("alert index[%d]", recordIndex);
free(ids[i]);
}
+ __currentIndex = recordIndex;
free(ids);
return;
return __alerts.size();
}
+size_t CalAlertData::getCurrentIndex() const
+{
+ for (size_t i = 0; i < __alerts.size(); ++i) {
+ if (__alerts[i]->getRecordIndex() == __currentIndex) {
+ return i;
+ }
+ }
+
+ return 0;
+}
+
std::shared_ptr<CalAlertNotificationItem> CalAlertData::getAt(int nth)
{
WENTER();
int getCount(void);
/**
+ * @brief Get current index of alert notification
+ * @see getAt()
+ * @detail Used to get index of current alert list
+ * @return Index of alert notification
+ */
+ size_t getCurrentIndex() const;
+
+ /**
* @brief Get element by number.
*
* @param nth number of item.
int __tick;
int __unit;
std::vector<std::shared_ptr<CalAlertNotificationItem>> __alerts;
+ int __currentIndex;
};
#endif
Evas_Object *layout = elm_layout_add(parent);
elm_layout_file_set(layout, CalPath::getPath(CAL_EDJE).c_str(), "CalAlertView");
- auto schedule = __model.getAt(0)->getSchedule();
+ auto &alertData = __model.getAlertData();
+ const auto &alertItem = alertData->getAt(alertData->getCurrentIndex());
+ auto schedule = alertItem->getSchedule();
std::string str;
//// add title
edje_object_signal_callback_add(dismiss, EMIT_ACTIVATED, "",
[](void *data, Evas_Object *, const char *, const char *) {
CalAlertView *self = (CalAlertView *)data;
- self->__model.dismiss(0);
+ self->__model.dismiss(self->__model.getAlertData()->getCurrentIndex());
ui_app_exit();
}, this);
edje_object_signal_callback_add(snooze, EMIT_ACTIVATED, "",
[](void *data, Evas_Object *, const char *, const char *) {
CalAlertView *self = (CalAlertView *)data;
- self->__model.snooze(0);
+ self->__model.snooze(self->__model.getAlertData()->getCurrentIndex());
ui_app_exit();
}, this);
__timer = ecore_timer_add(ALERT_TIMER, [](void *data) {
CalAlertView *self = (CalAlertView *)data;
- self->__model.snooze(0);
+ self->__model.snooze(self->__model.getAlertData()->getCurrentIndex());
self->__timer = NULL;
- elm_exit();
+ ui_app_exit();
return ECORE_CALLBACK_CANCEL;
}, this);