92 lines
2.6 KiB
C++
92 lines
2.6 KiB
C++
#ifndef TJDUIAPP_EBOOK_ADAPTER
|
|
#define TJDUIAPP_EBOOK_ADAPTER
|
|
|
|
#include <list>
|
|
#include "components/abstract_adapter.h"
|
|
#include "components/ui_image_view.h"
|
|
#include "components/ui_label_button.h"
|
|
#include "components/ui_label.h"
|
|
#include "components/ui_scroll_view.h"
|
|
#include "components/ui_view_group.h"
|
|
#include "components/ui_canvas_ext.h"
|
|
#include "TjdUiAppEbookView.h"
|
|
|
|
namespace TJD {
|
|
class TjdEbookItemView;
|
|
class EbookItemListener : public OHOS::UIView::OnClickListener
|
|
{
|
|
public:
|
|
EbookItemListener(TjdEbookItemView *item) : item_(item) {
|
|
view_ = TjdUiAppEbookView::GetInstance();
|
|
presenter_ = TjdUiAppEbookPresenter::GetInstance();
|
|
}
|
|
~EbookItemListener() {
|
|
item_ = nullptr;
|
|
view_ = nullptr;
|
|
presenter_ = nullptr;
|
|
}
|
|
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
|
private:
|
|
TjdEbookItemView *item_{nullptr};
|
|
TjdUiAppEbookView *view_{nullptr};
|
|
TjdUiAppEbookPresenter *presenter_{nullptr};
|
|
};
|
|
|
|
class EbookItemScrollView : public OHOS::UIScrollView
|
|
{
|
|
public:
|
|
EbookItemScrollView(){}
|
|
~EbookItemScrollView() {}
|
|
bool OnDragStartEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEndEvent(const OHOS::DragEvent& event) override;
|
|
|
|
private:
|
|
bool scrollEnable{true};
|
|
};
|
|
|
|
class TjdEbookItemView : public OHOS::UIViewGroup
|
|
{
|
|
public:
|
|
TjdEbookItemView();
|
|
~TjdEbookItemView();
|
|
void SetItemInfo(const EbookItem &itemInfo);
|
|
void SelectedChange();
|
|
void Reset();
|
|
EbookItem &GetItemInfo(void) { return itemInfo_; }
|
|
OHOS::UILabelButton *GetDeleteIcon(void) { return &deleteIcon_; }
|
|
OHOS::UIViewGroup *GetFillView(void) { return &fillView_; }
|
|
EbookItemScrollView *GetScrollView(void) { return &scrollContainer_; }
|
|
|
|
private:
|
|
OHOS::UIViewGroup fillView_;
|
|
OHOS::UILabel bookLabel_;
|
|
OHOS::UIImageView image_;
|
|
OHOS::UICanvasExt canvas_;
|
|
OHOS::UILabelButton deleteIcon_;
|
|
EbookItemScrollView scrollContainer_;
|
|
EbookItemListener itemListener_;
|
|
EbookItem itemInfo_;
|
|
};
|
|
|
|
class TjdEbookAdapter : public OHOS::AbstractAdapter
|
|
{
|
|
public:
|
|
explicit TjdEbookAdapter();
|
|
~TjdEbookAdapter();
|
|
|
|
uint16_t GetCount(void) override;
|
|
|
|
OHOS::UIView *GetView(OHOS::UIView *inView, int16_t index) override;
|
|
void DeleteListItem(uint32_t index);
|
|
EbookItem *GetListItem(uint32_t id);
|
|
std::list<EbookItem> &GetList(void) { return listData_; }
|
|
void DeleteListAllItem() { listData_.clear(); }
|
|
|
|
private:
|
|
std::list<EbookItem> listData_;
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |