modify animatorinflater,impl loadAnimator

This commit is contained in:
侯歌 2022-03-22 18:33:25 +08:00
parent 298fcab43e
commit d89fcb74ec
2 changed files with 27 additions and 3 deletions

View File

@ -77,13 +77,34 @@ StateListAnimator* AnimatorInflater::createStateListAnimatorFromXml(Context*ctx,
return nullptr; return nullptr;
} }
ObjectAnimator* AnimatorInflater::loadObjectAnimator(Context*ctx,const AttributeSet& attrs){ ObjectAnimator* AnimatorInflater::loadObjectAnimator(Context*ctx,const AttributeSet& atts){
ObjectAnimator*anim = new ObjectAnimator(); ObjectAnimator*anim = new ObjectAnimator();
loadValueAnimator(ctx,atts,anim);
return anim; return anim;
} }
ValueAnimator* AnimatorInflater::loadValueAnimator(Context*context,const AttributeSet& attrs, ValueAnimator*anim){ ValueAnimator* AnimatorInflater::loadValueAnimator(Context*context,const AttributeSet& atts, ValueAnimator*anim){
anim = new ValueAnimator(); if(anim==nullptr)
anim = new ValueAnimator();
anim->setDuration(atts.getInt("duration",300));
anim->setStartDelay(atts.getInt("startDelay",0));
anim->setRepeatCount(atts.getInt("repeatCount",0));
anim->setRepeatMode(atts.getInt("repeatMode",std::map<const std::string,int>{
{"restart" , (int)ValueAnimator::RESTART},
{"reverse" , (int)ValueAnimator::REVERSE},
{"infinite", (int)ValueAnimator::INFINITE}
},ValueAnimator::RESTART));
std::vector<float>values;
if(atts.hasAttribute("valueFrom")){
float f=atts.getFloat("valueFrom",.0f);
values.push_back(f);
}
if(atts.hasAttribute("valueTo")){
float f=atts.getFloat("valueTo",.0f);
values.push_back(f);
}
anim->setFloatValues(values);
return anim; return anim;
} }

View File

@ -61,6 +61,9 @@ TabLayout::~TabLayout(){
delete mTabTextColors; delete mTabTextColors;
delete mScrollAnimator; delete mScrollAnimator;
delete mAdapterChangeListener; delete mAdapterChangeListener;
if(mPagerAdapter&&mPagerAdapterObserver)
mPagerAdapter->unregisterDataSetObserver(mPagerAdapterObserver);
delete mPagerAdapterObserver;
} }
void TabLayout::initTabLayout(){ void TabLayout::initTabLayout(){