diff --git a/src/gui/animation/objectanimator.cc b/src/gui/animation/objectanimator.cc index a971ede2..fff523d2 100755 --- a/src/gui/animation/objectanimator.cc +++ b/src/gui/animation/objectanimator.cc @@ -35,12 +35,15 @@ void ObjectAnimator::setPropertyName(const std::string&propertyName){ } void ObjectAnimator::setProperty(const Property& property){ - if (mValuesMap.size()) { - /*PropertyValuesHolder valuesHolder = mValues[0]; - String oldName = valuesHolder.getPropertyName(); - valuesHolder.setProperty(property); - mValuesMap.remove(oldName); - mValuesMap.put(mPropertyName, valuesHolder);*/ + if (mValues.size()) { + PropertyValuesHolder* valuesHolder = mValues[0]; + std::string oldName = valuesHolder->getPropertyName(); + //valuesHolder->setProperty(property); + auto it=mValuesMap.find(oldName); + if(it!=mValuesMap.end()){ + mValuesMap.erase(it); + } + mValuesMap.insert(std::map::value_type(mPropertyName,valuesHolder)); } if (mProperty != nullptr) { mPropertyName = property.getName(); diff --git a/src/gui/animation/propertyvaluesholder.cc b/src/gui/animation/propertyvaluesholder.cc index 9e26eee8..5be34bcf 100755 --- a/src/gui/animation/propertyvaluesholder.cc +++ b/src/gui/animation/propertyvaluesholder.cc @@ -14,6 +14,10 @@ PropertyValuesHolder::PropertyValuesHolder(const std::string&name){ mProperty=nullptr; } +PropertyValuesHolder::~PropertyValuesHolder(){ + delete mProperty; +} + void PropertyValuesHolder::setPropertyName(const std::string& propertyName){ mPropertyName=propertyName; } @@ -22,8 +26,12 @@ const std::string PropertyValuesHolder::getPropertyName()const{ return mPropertyName; } -PropertyValuesHolder::~PropertyValuesHolder(){ - delete mProperty; +void PropertyValuesHolder::setProperty(Property*p){ + mProperty =p; +} + +Property*PropertyValuesHolder::getProperty(){ + return mProperty; } PropertyValuesHolder* PropertyValuesHolder::ofInt(const std::string&name,const std::vector&values){ diff --git a/src/gui/animation/propertyvaluesholder.h b/src/gui/animation/propertyvaluesholder.h index 4e1c5c8d..3021ce85 100755 --- a/src/gui/animation/propertyvaluesholder.h +++ b/src/gui/animation/propertyvaluesholder.h @@ -19,12 +19,14 @@ protected: Property*mProperty; public: PropertyValuesHolder(); + virtual ~PropertyValuesHolder(); PropertyValuesHolder(Property*prop); PropertyValuesHolder(const std::string&name); void setPropertyName(const std::string& propertyName); const std::string getPropertyName()const; + void setProperty(Property*p); + Property*getProperty(); virtual void setFraction(void*target,float fraction)=0; - virtual ~PropertyValuesHolder(); static PropertyValuesHolder*ofInt(const std::string&name,const std::vector&); static PropertyValuesHolder*ofInt(Property*,const std::vector&); static PropertyValuesHolder*ofFloat(const std::string&name,const std::vector&); diff --git a/src/gui/widget/progressbar.cc b/src/gui/widget/progressbar.cc index 1e7e5c35..43539b80 100755 --- a/src/gui/widget/progressbar.cc +++ b/src/gui/widget/progressbar.cc @@ -180,8 +180,8 @@ void ProgressBar::setVisualProgress(int id, float progress){ d = mCurrentDrawable; } } - if (d != nullptr) d->setLevel((progress * MAX_LEVEL)); - invalidate(true); + if (d) d->setLevel((progress * MAX_LEVEL)); + else invalidate(true); onVisualProgressChanged(id, progress); } @@ -208,7 +208,6 @@ void ProgressBar::doRefreshProgress(int id, int progress, bool fromUser,bool cal } else { setVisualProgress(id, scale); } - if (isPrimary && callBackToApp) { onProgressRefresh(scale, fromUser, progress); } @@ -250,7 +249,7 @@ void ProgressBar::refreshProgress(int id, int progress, bool fromUser,bool anima } mRefreshIsPosted=false; }; - postDelayed(mRefreshProgressRunnable,10); + post(mRefreshProgressRunnable); mRefreshIsPosted=true; } } diff --git a/src/gui/widget/window.cc b/src/gui/widget/window.cc index 39e7ccc4..56db8965 100755 --- a/src/gui/widget/window.cc +++ b/src/gui/widget/window.cc @@ -201,7 +201,7 @@ bool Window::dispatchKeyEvent(KeyEvent&event){ View* focused =getFocusedChild(); bool handled=false; const int action=event.getAction(); - if(focused && focus->dispatchKeyEvent(event)) + if(focused && focused->dispatchKeyEvent(event)) return true; int groupNavigationDirection = 0; if (action == KeyEvent::ACTION_DOWN && event.getKeyCode() == KEY_TAB) { @@ -230,20 +230,11 @@ bool Window::dispatchKeyEvent(KeyEvent&event){ bool Window::performFocusNavigation(KeyEvent& event){ int direction = -1; - //从下面代码可以看出,switch语句在此的主要作用是判断焦点的方向 switch (event.getKeyCode()) { - case KEY_DPAD_LEFT: - direction = View::FOCUS_LEFT; - break; - case KEY_DPAD_RIGHT: - direction = View::FOCUS_RIGHT; - break; - case KEY_DPAD_UP: - direction = View::FOCUS_UP; - break; - case KEY_DPAD_DOWN: - direction = View::FOCUS_DOWN; - break; + case KEY_DPAD_LEFT: direction = View::FOCUS_LEFT; break; + case KEY_DPAD_RIGHT: direction = View::FOCUS_RIGHT; break; + case KEY_DPAD_UP: direction = View::FOCUS_UP; break; + case KEY_DPAD_DOWN: direction = View::FOCUS_DOWN; break; case KEY_TAB: if (event.hasNoModifiers()) { direction = View::FOCUS_FORWARD; @@ -266,7 +257,7 @@ bool Window::performFocusNavigation(KeyEvent& event){ mView->offsetDescendantRectToMyCoords(focused, mTempRect); mView->offsetRectIntoDescendantCoords(v, mTempRect); } - LOGV("request focus at rect(%d,%d-%d,%d)",mTempRect.left,mTempRect.top,mTempRect.width,mTempRect.height); + LOGV("request focus at rect(%d,%d-%d,%d)",mTempRect.left,mTempRect.top,mTempRect.width,mTempRect.height); if (v->requestFocus(direction, &mTempRect)) { return true; }