1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_GALLERY_ABILITY_SLICE_H 17 #define OHOS_GALLERY_ABILITY_SLICE_H 18 19 #include <ability_loader.h> 20 #include <components/ui_image_view.h> 21 #include <components/ui_label.h> 22 #include <components/ui_scroll_view.h> 23 #include "event_listener.h" 24 #include "gallery_config.h" 25 26 namespace OHOS { 27 class GalleryAbilitySlice : public AbilitySlice { 28 public: 29 GalleryAbilitySlice() = default; 30 ~GalleryAbilitySlice() override; 31 32 protected: 33 void OnStart(const Want &want) override; 34 void OnInactive() override; 35 void OnActive(const Want &want) override; 36 void OnBackground() override; 37 void OnStop() override; 38 39 private: 40 void Clear(); 41 void ClearThumb(); 42 void ClearPictureList(const UIView* view); 43 void InitTitle(); 44 void InitPictureList(); 45 void AddAllPictures(const Point& pos, int16_t numInLine); 46 UIView* CreateImageItem(const Point& pos, const char* imageName, const char* imagePath); 47 EventListener* GetImageClickListener(const char* path); 48 void DeleteAllData(); 49 void DeleteAllFilesInDir(const char* path); 50 51 RootView* rootView_ { nullptr }; 52 uint16_t pictureCount_ { 0 }; 53 UIViewGroup* backArea_ { nullptr }; 54 UIImageView* backIcon_ { nullptr }; 55 EventListener* backIconListener_ { nullptr }; 56 EventListener* deleteClickListener_ { nullptr }; 57 UILabel* titleLabel_ { nullptr }; 58 UILabel* deleteLabel_ { nullptr }; 59 UIScrollView* picContainer_ { nullptr }; 60 UIViewGroup* picList_ { nullptr }; 61 char* pictureName_[MAX_PICTURE_COUNT] = { nullptr }; 62 char backIconAbsolutePath[MAX_PATH_LENGTH] = { 0 }; 63 char videoTagIconAbsolutePath[MAX_PATH_LENGTH] = { 0 }; 64 uint16_t pictureOnClickListenerCount_ { 0 }; 65 EventListener* pictureOnClickListener_[MAX_PICTURE_COUNT] = { nullptr }; 66 }; 67 } 68 #endif // OHOS_GALLERY_ABILITY_SLICE_H