From d89fcb74eca817954971ffd7ee7a795e7b66c0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E6=AD=8C?= Date: Tue, 22 Mar 2022 18:33:25 +0800 Subject: [PATCH] modify animatorinflater,impl loadAnimator --- src/gui/animation/animatorinflater.cc | 27 ++++++++++++++++++++++++--- src/gui/widget/tablayout.cc | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/gui/animation/animatorinflater.cc b/src/gui/animation/animatorinflater.cc index 392dd839..557541f3 100755 --- a/src/gui/animation/animatorinflater.cc +++ b/src/gui/animation/animatorinflater.cc @@ -77,13 +77,34 @@ StateListAnimator* AnimatorInflater::createStateListAnimatorFromXml(Context*ctx, return nullptr; } -ObjectAnimator* AnimatorInflater::loadObjectAnimator(Context*ctx,const AttributeSet& attrs){ +ObjectAnimator* AnimatorInflater::loadObjectAnimator(Context*ctx,const AttributeSet& atts){ ObjectAnimator*anim = new ObjectAnimator(); + loadValueAnimator(ctx,atts,anim); return anim; } -ValueAnimator* AnimatorInflater::loadValueAnimator(Context*context,const AttributeSet& attrs, ValueAnimator*anim){ - anim = new ValueAnimator(); +ValueAnimator* AnimatorInflater::loadValueAnimator(Context*context,const AttributeSet& atts, ValueAnimator*anim){ + 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{ + {"restart" , (int)ValueAnimator::RESTART}, + {"reverse" , (int)ValueAnimator::REVERSE}, + {"infinite", (int)ValueAnimator::INFINITE} + },ValueAnimator::RESTART)); + + std::vectorvalues; + 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; } diff --git a/src/gui/widget/tablayout.cc b/src/gui/widget/tablayout.cc index e4243341..bbcd1d6d 100755 --- a/src/gui/widget/tablayout.cc +++ b/src/gui/widget/tablayout.cc @@ -61,6 +61,9 @@ TabLayout::~TabLayout(){ delete mTabTextColors; delete mScrollAnimator; delete mAdapterChangeListener; + if(mPagerAdapter&&mPagerAdapterObserver) + mPagerAdapter->unregisterDataSetObserver(mPagerAdapterObserver); + delete mPagerAdapterObserver; } void TabLayout::initTabLayout(){