fix listpopupwindow's missing init

This commit is contained in:
侯歌 2022-05-13 10:35:19 +08:00
parent bdeaaeff9f
commit b88673806d
2 changed files with 7 additions and 5 deletions

View File

@ -9,6 +9,7 @@ DropDownListView::DropDownListView(Context*context,bool hijackfocus):ListView(co
DropDownListView::~DropDownListView(){
delete mScrollHelper;
removeCallbacks(mResolveHoverRunnable);
}
bool DropDownListView::shouldShowSelector(){
@ -18,7 +19,7 @@ bool DropDownListView::shouldShowSelector(){
bool DropDownListView::onTouchEvent(MotionEvent& ev){
if(mResolveHoverRunnable){
removeCallbacks(mResolveHoverRunnable);
mResolveHoverRunnable=nullptr;
mResolveHoverRunnable = nullptr;
}
return ListView::onTouchEvent(ev);
}
@ -29,7 +30,7 @@ bool DropDownListView::onHoverEvent(MotionEvent& ev){
// This may be transitioning to TOUCH_DOWN. Postpone drawable state
// updates until either the next frame or the next touch event.
mResolveHoverRunnable = [this](){
mResolveHoverRunnable=nullptr;
mResolveHoverRunnable = nullptr;
drawableStateChanged();
};
post(mResolveHoverRunnable);
@ -39,7 +40,7 @@ bool DropDownListView::onHoverEvent(MotionEvent& ev){
bool handled = ListView::onHoverEvent(ev);
if (action == MotionEvent::ACTION_HOVER_ENTER || action == MotionEvent::ACTION_HOVER_MOVE) {
int position = pointToPosition((int) ev.getX(), (int) ev.getY());
const int position = pointToPosition((int) ev.getX(), (int) ev.getY());
if (position != INVALID_POSITION && position != mSelectedPosition) {
View* hoveredItem = getChildAt(position - getFirstVisiblePosition());
if (hoveredItem->isEnabled()) {

View File

@ -34,6 +34,7 @@ ListPopupWindow::~ListPopupWindow(){
}
void ListPopupWindow::initPopupWindow(){
mObserver = nullptr;
mOverlapAnchor = 0xFF;
mDropDownAlwaysVisible = false;
mForceIgnoreOutsideTouch= false;
@ -330,7 +331,7 @@ void ListPopupWindow::dismiss() {
removePromptView();
mPopup->setContentView(nullptr);
mDropDownList->setAdapter(nullptr);
delete mDropDownList;
//delete mDropDownList;
mDropDownList = nullptr;
mHandler->removeCallbacks(mResizePopupRunnable);
}
@ -660,7 +661,7 @@ int ListPopupWindow::buildDropDown() {
// If we don't have an explicit vertical offset, determine one from
// the window background so that content will line up.
if (mDropDownVerticalOffset!=0){//!mDropDownVerticalOffsetSet) {
if (mDropDownVerticalOffset!=0){
mDropDownVerticalOffset = -mTempRect.top;
}
} else {