#include "components/ui_abstract_scroll_bar.h"
#include "gfx_utils/graphic_log.h"
-#if ENABLE_VIBRATOR
-#include "hal_tick.h"
-#endif
namespace OHOS {
UIList::Recycle::~Recycle()
UIList::UIList() : UIList(VERTICAL) {}
-/* --------------------------------- 减少震动次数 --------------------------------- */
-static uint32_t lastVibratorTime_;
-static constexpr uint32_t MIN_VIBRATOR_INTERVAL_MS = 100; // 最小振动间隔100毫秒
-/* -------------------------------------------------------------------------- */
-
UIList::UIList(uint8_t direction)
: onSelectedView_(nullptr),
isLoopList_(false),
#if ENABLE_VIBRATOR
needVibration_ = false;
vibratorType_ = VibratorType::VIBRATOR_TYPE_ONE;
- lastVibratorTime_ = 0;
#endif
#if ENABLE_FOCUS_MANAGER
focusable_ = true;
}
}
#if ENABLE_VIBRATOR
- VibratorFunc vibratorFunc = VibratorManager::GetInstance()->GetVibratorFunc();
- if (isSelectViewFind && needVibration_ && vibratorFunc != nullptr) {
- printf("isSelectViewFind = %d\n", isSelectViewFind);
- uint32_t currentTime = HALTick::GetInstance().GetTime();
- // 只有在规定时间间隔后才允许调用振动(首次调用时lastVibratorTime_为0,允许调用)
- bool canVibrate = (lastVibratorTime_ == 0) ||
- (HALTick::GetInstance().GetElapseTime(lastVibratorTime_) >= MIN_VIBRATOR_INTERVAL_MS);
- if (canVibrate) {
- if (!isLoopList_ && (onSelectedIndex_ == 0 || onSelectedIndex_ == recycle_.adapter_->GetCount() - 1)) {
- vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE);
- GRAPHIC_LOGI("UIList::MoveChildByOffset calls TYPE_THREE vibrator");
- } else {
- vibratorFunc(VibratorType::VIBRATOR_TYPE_TWO);
- GRAPHIC_LOGI("UIList::MoveChildByOffset calls TYPE_TWO vibrator");
- }
- lastVibratorTime_ = currentTime;
- }
- }
- #if 0
VibratorFunc vibratorFunc = VibratorManager::GetInstance()->GetVibratorFunc();
if (isSelectViewFind && needVibration_ && vibratorFunc != nullptr) {
if (!isLoopList_ && (onSelectedIndex_ == 0 || onSelectedIndex_ == recycle_.adapter_->GetCount() - 1)) {
GRAPHIC_LOGI("UIList::MoveChildByOffset calls TYPE_TWO vibrator");
}
}
- #endif
#endif
}
view = view->GetNextSibling();