#ifndef TJDUIAPP_ALBUM_VIEW #define TJDUIAPP_ALBUM_VIEW #include "TjdUiAppAlbumAdapter.h" #include "TjdUiAppAlbumModel.h" #include "TjdUiAppSettingPage.h" #include "View.h" #include "components/ui_list_nested.h" #include "components/ui_scroll_view_nested.h" #include "graphic_timer.h" #include "ui_image_animator.h" #include "ui_label_button.h" #include "ui_label_ext.h" #include "ui_list.h" #include "ui_slider.h" #include "ui_view_group.h" #include namespace TJD { class AlbumVideoOnClickListener : public OHOS::UIView::OnClickListener { public: AlbumVideoOnClickListener(AlbumVideoPlayer *player, OHOS::UILabel *totalTime, OHOS::Animator *animator); ~AlbumVideoOnClickListener(); bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; void PauseResumeButtonSwitch(AlbumIconType icon); void VideoForward(void); void VideoBackward(void); void LoadVideoStart(void); void SetVideoWallPaper(void); private: OHOS::UILabel *totalTime_ = nullptr; OHOS::Animator *animator_ = nullptr; AlbumVideoPlayer *player_ = nullptr; OHOS::GraphicTimer *timer_ = nullptr; }; class AlbumVideoAnimatorCallback : public OHOS::AnimatorCallback { public: AlbumVideoAnimatorCallback(OHOS::UILabel *curLabel, OHOS::UILabel *totalLabel, OHOS::UISlider *slider, OHOS::UIButton *button) : curlabel_(curLabel), totallabel_(totalLabel), slider_(slider), button_(button) { } void Callback(OHOS::UIView *view) override; void OnStop(OHOS::UIView &view) override; bool SetAnimator(OHOS::Animator *animator); private: OHOS::UILabel *curlabel_ = nullptr; OHOS::UILabel *totallabel_ = nullptr; OHOS::UISlider *slider_ = nullptr; OHOS::UIButton *button_ = nullptr; OHOS::Animator *videoAnimator_ = nullptr; uint32_t lastTime = 0; }; class AlbumWaitView : public OHOS::UIScrollView { public: AlbumWaitView(); ~AlbumWaitView(); void ShowView(); void HideView(); void Stop() { animator_.Stop(); } private: OHOS::UIImageAnimatorView animator_; OHOS::UILabelExt desc_; }; class AlbumSurfaceView : public OHOS::UILiteSurfaceView { public: AlbumSurfaceView() {} ~AlbumSurfaceView() { UnsetPreview(); } void SetPreview(std::string res); void UnsetPreview(); private: std::string lastRes_ = {""}; }; class AlbumUIScrollView : public OHOS::UIScrollViewNested { public: AlbumUIScrollView() {} ~AlbumUIScrollView() {} bool OnDragStartEvent(const OHOS::DragEvent &event) override; bool OnDragEvent(const OHOS::DragEvent &event) override; bool OnDragEndEvent(const OHOS::DragEvent &event) override; private: bool isOnStart_{false}; }; class TjdUiAppAlbumPresenter; class TjdUiAppAlbumView : public OHOS::View { public: TjdUiAppAlbumView(); ~TjdUiAppAlbumView(); static TjdUiAppAlbumView *GetInstance(void); void OnStart() override; void OnStop() override; OHOS::UIListNested *GetUIList(void) { return contentList_; } TjdAlbumAdapter *GetAdapter() { return listAdapter_; } std::list &GetAdapterList(void) { return listAdapter_->GetList(); } void DeleteAlbumItemFromList(uint8_t index); OHOS::UIScrollViewNested *ListViewInit(void); OHOS::UIScrollView *PhotoViewInit(void); OHOS::UIScrollView *VideoViewInit(void); OHOS::UIScrollView *SettingViewInit(void); bool ShowListView(AlbumView hideView); bool ShowPhotoView(AlbumView hideView); bool ShowVideoView(AlbumView hideView); bool ShowSettingView(AlbumView hideView); bool ChangeView(AlbumView view, AlbumView hideView); void ResetListPosition(void); void RefreshListView(void); void EnterWallPaperSet(bool); void EnterSetFail(bool); void EnterSetSucc(void); void StartJumpTimer(); void StopJumpTimer(); void JumpTimerCallback(void); AlbumVideoPlayer *GetVideoPlayer(void) { return videoPlay_; } std::map viewHierarchy = {{AlbumView::ALBUM_PHOTO_VIEW, AlbumView::ALBUM_LIST_VIEW}, {AlbumView::ALBUM_VIDEO_VIEW, AlbumView::ALBUM_LIST_VIEW}, {AlbumView::ALBUM_SETTING_VIEW, AlbumView::ALBUM_PHOTO_VIEW}}; bool isEnterWallPaperSet_{false}; bool isSetWallPaperFail_{false}; bool isEnterFromVideo_{false}; private: typedef bool (TjdUiAppAlbumView::*AlbumChangeView)(AlbumView); AlbumChangeView viewMapper_[ALBUM_VIEW_MAX] = {&TjdUiAppAlbumView::ShowListView, &TjdUiAppAlbumView::ShowPhotoView, &TjdUiAppAlbumView::ShowVideoView, &TjdUiAppAlbumView::ShowSettingView}; OHOS::UIViewGroup *groupList_[AlbumView::ALBUM_VIEW_MAX]{nullptr}; OHOS::UIListNested *contentList_{nullptr}; TjdAlbumAdapter *listAdapter_{nullptr}; AlbumUIScrollView *containerAll_{nullptr}; OHOS::UIScrollViewNested *listContainer_{nullptr}; OHOS::UIScrollView *photoContainer_{nullptr}; OHOS::UIScrollView *videoContainer_{nullptr}; OHOS::UIScrollView *settingContainer_{nullptr}; OHOS::UIImageView *selectedPhoto_{nullptr}; OHOS::ColorType colorKey_; AlbumSurfaceView *surfaceView_{nullptr}; OHOS::UIButton *buttonArray_[ALBUM_BUTTON_NUM]{nullptr}; AlbumVideoPlayer *videoPlay_{nullptr}; AlbumVideoOnClickListener *clickListener{nullptr}; OHOS::UIScrollView *playContainer_{nullptr}; OHOS::UISlider *videoSlider_{nullptr}; OHOS::UILabel *videoTotalTime_{nullptr}; OHOS::UILabel *videoCurTime_{nullptr}; OHOS::Animator *videoAnimator_{nullptr}; AlbumVideoAnimatorCallback *animatorCallback_{nullptr}; AlbumWaitView *setWaitAnimator_{nullptr}; OHOS::GraphicTimer *setTimer_{nullptr}; osTimerId_t jumpTimerId_{nullptr}; uint8_t jumpTimerCount_{0}; }; } // namespace TJD #endif