*/
std::string GetTimezoneDiffDescription(int local_timezone_offset, int timezone_offset);
+/**
+ * @brief Retrieves seconds to the next exact minute(e.g. for 15:33:44:200 the returned is 15,800)
+ *
+ * @return seconds to round minute
+ */
+double GetSecondsToNextExactMinute();
}
#endif /* _CLOCK_UTILS_WORLDCLOCK_H_ */
Evas_Object *select_all_checkbox_;
/**
+ * @brief Timer for time and date updating
+ */
+ Ecore_Timer *timer_;
+
+ /**
* @brief Item class for the main content genlist
*/
static Elm_Genlist_Item_Class world_clock_delete_view_itc_;
* @brief Emits LIST_ITEM_CLICKED signal and toggle checkbox state.
*/
static void ItemSelectToggle(void *data, Evas_Object *obj, void *event_info);
+
+ /**
+ * @brief Timer callback for time updates.
+ * @param data user data
+ * @return EINA_BOOL to allow next invocation of callback, EINA_FALSE otherwise
+ */
+ static Eina_Bool TimeUpdateCb(void *data);
};
} /* view */
static Elm_Genlist_Item_Class world_clock_reorder_items_view_itc_;
/**
+ * @brief Timer for time and date updating
+ */
+ Ecore_Timer *timer_;
+
+ /**
* @brief list of signals
*/
std::vector<std::function<void(void)>> signals_
* @remarks Invoked by clicking BACK naviframe button or back hardware key
*/
static void OnBackButtonClicked(void *data, Evas_Object *obj, void *event_info);
+
+ /**
+ * @brief Timer callback for time updates.
+ * @param data user data
+ * @return EINA_BOOL to allow next invocation of callback, EINA_FALSE otherwise
+ */
+ static Eina_Bool TimeUpdateCb(void *data);
};
} /* view */
CUSTOM_LIST_ITEM_CLICKED,
CUSTOM_LIST_ITEM_ADD,
+ CUSTOM_LIST_UPDATE_REQUEST,
MAX
};
};
WorldClockView(ui::IView &main);
+ ~WorldClockView();
Evas_Object *GetEvasObject(){return world_clock_main_;};
static void AddLocationReplayCb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data);
+ /**
+ * @brief Timer callback for time updates.
+ * @param data user data
+ * @return EINA_BOOL to allow next invocation of callback, EINA_FALSE otherwise
+ */
+ static Eina_Bool TimeUpdateCb(void *data);
+
void SetItemLastClicked(const model::Location *location);
void SetItemToAdd(model::Location *l);
void EmitSignal(view::WorldClockSignals signal);
const model::Location *item_last_clicked_;
const model::Location *item_to_add_;
+ /**
+ * @brief Timer for time and date updating
+ */
+ Ecore_Timer *timer_;
+
std::vector<std::function<void(void)>> signals
= std::vector<std::function<void(void)>>((int)WorldClockSignals::MAX, nullptr);
};
WorldClockSignals::CUSTOM_LIST_ITEM_CLICKED);
view_->RegisterSignal(std::bind(&WorldClockPresenter::OnItemAdded, this),
WorldClockSignals::CUSTOM_LIST_ITEM_ADD);
+ view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMapViewUpdateRequest, this),
+ WorldClockSignals::CUSTOM_LIST_UPDATE_REQUEST);
view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreButtonClicked, this),
WorldClockSignals::BUTTON_MORE_CLICKED);
view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreDeleteButtonClicked, this),
WorldClockSignals::BUTTON_MORE_DELETE_CLICKED);
view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreReorderButtonClicked, this),
- WorldClockSignals::BUTTON_MORE_REORDER_CLICKED);
+ WorldClockSignals::BUTTON_MORE_REORDER_CLICKED);
model_->RegisterSignalHandler(WorldClock::ParameterSignalType::USER_LOCATION_REMOVED,
std::bind(&WorldClockPresenter::OnItemDeleted, this, _1));
model_->RegisterSignalHandler(WorldClock::SignalType::CUSTOM_LIST_CHANGED,
std::bind(&WorldClockPresenter::OnCustomListChanged, this));
- view_->UpdateMapAndTimezoneDetails(model_->GetCurrentTimezone());
+ OnMapViewUpdateRequest();
for (auto it = model_->user_locations_.begin(); it != model_->user_locations_.end(); it++)
view_->AppendItemToCustomList(*it);
void WorldClockPresenter::OnLeftArrowButtonClicked()
{
model_->MoveCurrentTimezone(model::WorldClock::LEFT);
- view_->UpdateMapAndTimezoneDetails(model_->GetCurrentTimezone());
+ OnMapViewUpdateRequest();
}
void WorldClockPresenter::OnRightArrowButtonClicked()
{
model_->MoveCurrentTimezone(model::WorldClock::RIGHT);
- view_->UpdateMapAndTimezoneDetails(model_->GetCurrentTimezone());
+ OnMapViewUpdateRequest();
}
void WorldClockPresenter::OnCustomListItemClicked()
const model::Location *location = view_->GetLastClickedItem();
model_->SetCurrentTimezone(model_->GetTimezoneByOffset(location->gmt_offset_));
- view_->UpdateMapAndTimezoneDetails(model_->GetCurrentTimezone());
+ OnMapViewUpdateRequest();
}
}
model_->SetCurrentTimezone(t);
- view_->UpdateMapAndTimezoneDetails(model_->GetCurrentTimezone());
+ OnMapViewUpdateRequest();
view_->AppendItemToCustomList(l);
} else {
view_->PostItemExistMessage();
#include <app_i18n.h>
#include "Utils/WorldClock.h"
+#include "Utils/Time.h"
namespace utils {
// local_timezone_offset and timezone_offset should be relative to GMT
return relative;
}
+
+double GetSecondsToNextExactMinute()
+{
+ Time t = Time::Now();
+ double s = t.GetSecond();
+ double ms = t.GetMilliSec();
+ double diff = 60 - s - (ms / 1000);
+ return diff;
+}
+
} /* utils */
#include <efl_extension.h>
#include <vector>
#include <sstream>
+#include <tuple>
+
#include "View/WorldClockDeleteItemsView.h"
#include "Internal/WorldClockDefs.h"
#include "Model/Location.h"
return content_;
}
+Eina_Bool WorldClockDeleteItemsView::TimeUpdateCb(void *data)
+{
+ WorldClockDeleteItemsView *view = static_cast<WorldClockDeleteItemsView *>(data);
+ elm_genlist_realized_items_update(view->content_);
+
+ ecore_timer_interval_set(view->timer_, utils::GetSecondsToNextExactMinute());
+
+ return EINA_TRUE;
+}
+
void WorldClockDeleteItemsView::CreateContent(Evas_Object *parent)
{
+ double time_delta;
+
elm_object_item_style_set(navi_item_, "basic");
static bool extension_init = false;
elm_object_item_part_content_set(navi_item_, "title_right_btn", right_button_);
elm_object_item_content_set(navi_item_, content_);
+ time_delta = utils::GetSecondsToNextExactMinute();
+
+ timer_ = ecore_timer_add(time_delta, WorldClockDeleteItemsView::TimeUpdateCb, this);
+ if (!timer_)
+ FAT("Unable to create timer!");
CreateSelectAll();
}
void WorldClockDeleteItemsView::DestroyContent()
{
+ ecore_timer_del(timer_);
evas_object_del(content_);
evas_object_del(left_button_);
evas_object_del(right_button_);
}
}
+Eina_Bool WorldClockReorderView::TimeUpdateCb(void *data)
+{
+ WorldClockReorderView *view = static_cast<WorldClockReorderView *>(data);
+ elm_genlist_realized_items_update(view->content_);
+
+ ecore_timer_interval_set(view->timer_, utils::GetSecondsToNextExactMinute());
+
+ return EINA_TRUE;
+}
void WorldClockReorderView::CreateContent(Evas_Object *parent)
{
+ double time_delta;
+
elm_object_item_style_set(navi_item_, "basic");
static bool extension_init = false;
elm_object_item_content_set(navi_item_, content_);
evas_object_smart_callback_add(content_, "moved" , OnListReordered, this);
+
+ time_delta = utils::GetSecondsToNextExactMinute();
+
+ timer_ = ecore_timer_add(time_delta, WorldClockReorderView::TimeUpdateCb, this);
+ if (!timer_)
+ FAT("Unable to create timer!");
}
void WorldClockReorderView::DestroyContent()
{
+ ecore_timer_del(timer_);
evas_object_del(content_);
evas_object_del(left_button_);
}
}
}
+Eina_Bool WorldClockView::TimeUpdateCb(void *data)
+{
+ WorldClockView *view = static_cast<WorldClockView *>(data);
+ elm_genlist_realized_items_update(view->custom_locations_list_);
+ view->EmitSignal(view::WorldClockSignals::CUSTOM_LIST_UPDATE_REQUEST);
+
+ ecore_timer_interval_set(view->timer_, utils::GetSecondsToNextExactMinute());
+
+ return EINA_TRUE;
+}
+
WorldClockView::WorldClockView(ui::IView &main)
{
+ double time_delta;
+
world_clock_main_ = elm_layout_add(main.GetEvasObject());
evas_object_size_hint_align_set(world_clock_main_, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(world_clock_main_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_layout_signal_callback_add(world_clock_, "timezone,go,right",
"main.world.map:arrow.right", ChangeTimezoneCb,
static_cast<void *>(this));
+
+ time_delta = utils::GetSecondsToNextExactMinute();
+
+ timer_ = ecore_timer_add(time_delta, WorldClockView::TimeUpdateCb, this);
+ if (!timer_)
+ FAT("Unable to create timer!");
}
+WorldClockView::~WorldClockView()
+{
+ ecore_timer_del(timer_);
+}
void WorldClockView::MoreButtonClicked(void *data, Evas_Object *obj, void *info)
{