1 /* 2 * Copyright (c) 2024 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 COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H 17 #define COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H 18 19 #include <functional> 20 21 #include "base/memory/ace_type.h" 22 23 namespace OHOS::Ace::NG { 24 25 class MovingPhotoController : public virtual AceType { 26 DECLARE_ACE_TYPE(MovingPhotoController, AceType) 27 28 public: 29 MovingPhotoController() = default; 30 ~MovingPhotoController() override = default; 31 32 using StartPlaybackImpl = std::function<void()>; 33 using StopPlaybackImpl = std::function<void()>; 34 using RefreshMovingPhotoImpl = std::function<void()>; 35 SetStartPlaybackImpl(StartPlaybackImpl && startPlaybackImpl)36 void SetStartPlaybackImpl(StartPlaybackImpl&& startPlaybackImpl) 37 { 38 startPlaybackImpl_ = std::move(startPlaybackImpl); 39 } 40 StartPlayback()41 void StartPlayback() 42 { 43 if (startPlaybackImpl_) { 44 startPlaybackImpl_(); 45 } 46 } 47 SetStopPlaybackImpl(StopPlaybackImpl && stopPlaybackImpl)48 void SetStopPlaybackImpl(StopPlaybackImpl&& stopPlaybackImpl) 49 { 50 stopPlaybackImpl_ = std::move(stopPlaybackImpl); 51 } 52 StopPlayback()53 void StopPlayback() 54 { 55 if (stopPlaybackImpl_) { 56 stopPlaybackImpl_(); 57 } 58 } 59 SetRefreshMovingPhotoImpl(RefreshMovingPhotoImpl && refreshMovingPhotoImpl)60 void SetRefreshMovingPhotoImpl(RefreshMovingPhotoImpl&& refreshMovingPhotoImpl) 61 { 62 refreshMovingPhotoImpl_ = std::move(refreshMovingPhotoImpl); 63 } 64 RefreshMovingPhoto()65 void RefreshMovingPhoto() 66 { 67 if (refreshMovingPhotoImpl_) { 68 refreshMovingPhotoImpl_(); 69 } 70 } 71 72 private: 73 StartPlaybackImpl startPlaybackImpl_; 74 StopPlaybackImpl stopPlaybackImpl_; 75 RefreshMovingPhotoImpl refreshMovingPhotoImpl_; 76 }; 77 78 } // namespace OHOS::Ace::NG 79 80 #endif // COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H