93 lines
2.6 KiB
C++
93 lines
2.6 KiB
C++
#ifndef TJDUIAPP_ALARM_ADAPTER
|
|
#define TJDUIAPP_ALARM_ADAPTER
|
|
|
|
#include "TjdUiAppAlarmPresenter.h"
|
|
#include "TjdUiAppAlarmView.h"
|
|
#include "abstract_adapter.h"
|
|
#include "components/ui_label.h"
|
|
#include "components/ui_toggle_button.h"
|
|
#include "components/ui_view_group.h"
|
|
|
|
namespace TJD {
|
|
class TjdAlarmItemView;
|
|
class TjdUiAppAlarmView;
|
|
class TjdUiAppAlarmPresenter;
|
|
|
|
class AlarmItemListener : public OHOS::UIView::OnClickListener,
|
|
public OHOS::UIView::OnDragListener,
|
|
public OHOS::UICheckBox::OnChangeListener
|
|
{
|
|
public:
|
|
AlarmItemListener(TjdAlarmItemView *item) : item_(item)
|
|
{
|
|
view_ = TjdUiAppAlarmView::GetInstance();
|
|
presenter_ = TjdUiAppAlarmPresenter::GetInstance();
|
|
}
|
|
~AlarmItemListener()
|
|
{
|
|
item_ = nullptr;
|
|
view_ = nullptr;
|
|
presenter_ = nullptr;
|
|
}
|
|
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
|
bool OnChange(OHOS::UICheckBox::UICheckBoxState state) override;
|
|
|
|
private:
|
|
TjdUiAppAlarmView *view_{nullptr};
|
|
TjdUiAppAlarmPresenter *presenter_{nullptr};
|
|
TjdAlarmItemView *item_{nullptr};
|
|
};
|
|
|
|
class TjdAlarmItemView : public OHOS::UIViewGroup
|
|
{
|
|
public:
|
|
TjdAlarmItemView();
|
|
~TjdAlarmItemView();
|
|
void SetItemInfo(const AlarmItem &itemInfo);
|
|
void SelectedChange();
|
|
void Reset();
|
|
AlarmItem GetItemInfo(void) { return itemInfo_; }
|
|
|
|
class ItemButton : public OHOS::UIToggleButton
|
|
{
|
|
public:
|
|
bool OnClickEvent(const OHOS::ClickEvent &event) override
|
|
{
|
|
OHOS::UIToggleButton::OnClickEvent(event);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
const char *GetTimeStr(void) { return timeLabel_.GetText();}
|
|
const char *GetWeekStr(void) { return weekLabel_.GetText();}
|
|
|
|
private:
|
|
ItemButton button_;
|
|
OHOS::UILabel timeLabel_;
|
|
OHOS::UILabel weekLabel_;
|
|
AlarmItemListener itemListener_;
|
|
AlarmItem itemInfo_ = {0, false, 0, 0, 0};
|
|
};
|
|
|
|
class TjdAlarmAdapter : public OHOS::AbstractAdapter
|
|
{
|
|
public:
|
|
explicit TjdAlarmAdapter() {}
|
|
~TjdAlarmAdapter() { listData_.clear(); }
|
|
|
|
uint16_t GetCount(void) override { return listData_.size(); }
|
|
OHOS::UIView *GetView(OHOS::UIView *inView, int16_t index) override;
|
|
|
|
void AddListItem(AlarmItem &item) { listData_.emplace_back(item); }
|
|
void DeleteListItem(uint8_t index);
|
|
AlarmItem *GetListItem(uint8_t index);
|
|
std::list<AlarmItem> &GetList(void) { return listData_; }
|
|
void DeleteListAllItem() { listData_.clear(); }
|
|
|
|
private:
|
|
std::list<AlarmItem> listData_;
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |