提交 0a556977 编写于 作者: O openharmony_ci 提交者: Gitee

!472 移除ui_picker组件中无用的成员变量

Merge pull request !472 from JayLeeHW/master-uipicker-bug
...@@ -92,7 +92,6 @@ UIPicker::UIPicker() ...@@ -92,7 +92,6 @@ UIPicker::UIPicker()
isHeightSet_(false), isHeightSet_(false),
textAdapter_(nullptr), textAdapter_(nullptr),
maxCount_(0), maxCount_(0),
setSelectedIndex_(0),
isScrollBlankSizeSet_(false), isScrollBlankSizeSet_(false),
scrollBlankSize_(0), scrollBlankSize_(0),
backgroundFontSize_(0), backgroundFontSize_(0),
...@@ -199,14 +198,17 @@ void UIPicker::Refresh() ...@@ -199,14 +198,17 @@ void UIPicker::Refresh()
bool UIPicker::RefreshValues(int16_t start, int16_t end) bool UIPicker::RefreshValues(int16_t start, int16_t end)
{ {
if (!isWidthSet_ || !isHeightSet_ || !itemsHeight_ || ((start == 0) && (end == 0))) { if ((start == 0) && (end == 0)) {
return false;
}
maxCount_ = end - start + 1;
if (!isWidthSet_ || !isHeightSet_ || !itemsHeight_) {
return false; return false;
} }
uint16_t userSelectIndex = listListener_->GetSelectIndex(); uint16_t userSelectIndex = listListener_->GetSelectIndex();
ClearList(); ClearList();
InitTextAdapter(); InitTextAdapter();
textAdapter_->SetData(start, end); textAdapter_->SetData(start, end);
maxCount_ = end - start + 1;
RefreshList(); RefreshList();
RefreshSelected(userSelectIndex); RefreshSelected(userSelectIndex);
return true; return true;
...@@ -214,7 +216,11 @@ bool UIPicker::RefreshValues(int16_t start, int16_t end) ...@@ -214,7 +216,11 @@ bool UIPicker::RefreshValues(int16_t start, int16_t end)
bool UIPicker::RefreshValues(const char* value[], uint16_t count) bool UIPicker::RefreshValues(const char* value[], uint16_t count)
{ {
if (value == nullptr || !isWidthSet_ || !isHeightSet_ || !itemsHeight_) { if (value == nullptr) {
return false;
}
maxCount_ = count;
if (!isWidthSet_ || !isHeightSet_ || !itemsHeight_) {
return false; return false;
} }
uint16_t userSelectIndex = listListener_->GetSelectIndex(); uint16_t userSelectIndex = listListener_->GetSelectIndex();
...@@ -224,7 +230,6 @@ bool UIPicker::RefreshValues(const char* value[], uint16_t count) ...@@ -224,7 +230,6 @@ bool UIPicker::RefreshValues(const char* value[], uint16_t count)
} }
InitTextAdapter(); InitTextAdapter();
textAdapter_->SetData(&dataList_); textAdapter_->SetData(&dataList_);
maxCount_ = count;
RefreshList(); RefreshList();
RefreshSelected(userSelectIndex); RefreshSelected(userSelectIndex);
...@@ -267,13 +272,12 @@ void UIPicker::ClearValues() ...@@ -267,13 +272,12 @@ void UIPicker::ClearValues()
{ {
rangeValue_ = nullptr; rangeValue_ = nullptr;
rangeValueCount_ = 0; rangeValueCount_ = 0;
setSelectedIndex_ = 0; maxCount_ = 0;
ClearList(); ClearList();
} }
void UIPicker::ClearList() void UIPicker::ClearList()
{ {
maxCount_ = 0;
itemsWidth_ = 0; itemsWidth_ = 0;
if (listListener_) { if (listListener_) {
listListener_->SetSelectView(nullptr); listListener_->SetSelectView(nullptr);
...@@ -285,7 +289,6 @@ void UIPicker::ClearList() ...@@ -285,7 +289,6 @@ void UIPicker::ClearList()
bool UIPicker::SetSelected(uint16_t index) bool UIPicker::SetSelected(uint16_t index)
{ {
setSelectedIndex_ = index;
return RefreshSelected(index); return RefreshSelected(index);
} }
...@@ -295,7 +298,6 @@ bool UIPicker::RefreshSelected(uint16_t index) ...@@ -295,7 +298,6 @@ bool UIPicker::RefreshSelected(uint16_t index)
GRAPHIC_LOGW("Failed to refresh selected since index is beyond range!"); GRAPHIC_LOGW("Failed to refresh selected since index is beyond range!");
return false; return false;
} }
listListener_->SetSelectIndex(index);
if (itemsHeight_ && (list_.GetChildrenHead() != nullptr) && isWidthSet_ && isHeightSet_) { if (itemsHeight_ && (list_.GetChildrenHead() != nullptr) && isWidthSet_ && isHeightSet_) {
listListener_->SetInitStatus(false); listListener_->SetInitStatus(false);
// 2: half // 2: half
...@@ -331,9 +333,11 @@ bool UIPicker::RefreshSelected(uint16_t index) ...@@ -331,9 +333,11 @@ bool UIPicker::RefreshSelected(uint16_t index)
} }
childView = childView->GetNextSibling(); childView = childView->GetNextSibling();
} }
listListener_->SetSelectIndex(index);
list_.Invalidate(); list_.Invalidate();
return true; return true;
} }
listListener_->SetSelectIndex(index);
return false; return false;
} }
......
...@@ -536,7 +536,6 @@ protected: ...@@ -536,7 +536,6 @@ protected:
TextAdapter* textAdapter_; TextAdapter* textAdapter_;
uint16_t maxCount_; uint16_t maxCount_;
PickerListScrollListener* listListener_; PickerListScrollListener* listListener_;
uint16_t setSelectedIndex_;
private: private:
friend class PickerListScrollListener; friend class PickerListScrollListener;
bool RefreshValues(const char* value[], uint16_t count); bool RefreshValues(const char* value[], uint16_t count);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册