fix uieventsource.removeCallbacks

This commit is contained in:
houzh 2022-03-31 14:50:42 +00:00
parent ff8b5953ef
commit 61b8af9476
4 changed files with 12 additions and 9 deletions

View File

@ -76,14 +76,15 @@ bool UIEventSource::hasDelayedRunners()const{
return runner.time<nowms;
}
bool UIEventSource::removeCallbacks(const Runnable& what){
int UIEventSource::removeCallbacks(const Runnable& what){
int count=0;
for(auto it=mRunnables.begin();it!=mRunnables.end();it++){
if(it->run==what){
if((it->run==what)&&(it->removed==false)){
it->removed=true;
return true;
count++;
}
}
return false;
return count;
}
}//end namespace

View File

@ -24,7 +24,7 @@ public:
int checkEvents()override;
int handleEvents()override;
bool postDelayed(Runnable& run,uint32_t delay=0);
bool removeCallbacks(const Runnable& what);
int removeCallbacks(const Runnable& what);
};
}//end namespace

View File

@ -141,7 +141,7 @@ public:
}
void run(){
long now = AnimationUtils::currentAnimationTimeMillis();
if (now >= fadeStartTime) {
if (host && (now >= fadeStartTime)) {
// the animation fades the scrollbars out by changing
// the opacity (alpha) from fully opaque to fully
// transparent
@ -1323,8 +1323,10 @@ void View::dispatchDetachedFromWindow(){
conts.erase(it);
mPrivateFlags &= ~PFLAG_SCROLL_CONTAINER_ADDED;
}
if(mScrollCache&&mScrollCache->mRunner)
removeCallbacks(mScrollCache->mRunner);
if(mScrollCache&&mScrollCache->mRunner){
removeCallbacks(mScrollCache->mRunner);
mScrollCache->mRunner.reset();
}
mAttachInfo = nullptr;
if(mOverlay)
mOverlay->getOverlayView()->dispatchDetachedFromWindow();

View File

@ -586,7 +586,7 @@ void ViewPager::populate(int newCurrentItem){
if (pos == ii->position && !ii->scrolling) {
mItems.erase(mItems.begin()+itemIndex);
mAdapter->destroyItem(this, pos, ii->object);
LOGD("destroyItem() with pos:%d/%d view:%p curitem=%d/%d",pos,ii->position,ii->object,mCurItem,mItems.size());
LOGV("destroyItem() with pos:%d/%d view:%p curitem=%d/%d",pos,ii->position,ii->object,mCurItem,mItems.size());
delete ii;
itemIndex--;
curIndex--;