This source file includes following definitions.
- AnimationProgressed
- GetAnimation
- AddObserver
- RemoveObserver
- GetInstance
#include "ash/system/chromeos/network/network_icon_animation.h"
#include "ash/system/chromeos/network/network_icon_animation_observer.h"
namespace {
const int kThrobDurationMs = 750;
}
namespace ash {
namespace network_icon {
NetworkIconAnimation::NetworkIconAnimation()
: animation_(this) {
animation_.SetThrobDuration(kThrobDurationMs);
animation_.SetTweenType(gfx::Tween::LINEAR);
}
NetworkIconAnimation::~NetworkIconAnimation() {
}
void NetworkIconAnimation::AnimationProgressed(
const gfx::Animation* animation) {
if (animation != &animation_)
return;
FOR_EACH_OBSERVER(AnimationObserver, observers_, NetworkIconChanged());
}
double NetworkIconAnimation::GetAnimation() {
if (!animation_.is_animating()) {
animation_.Reset();
animation_.StartThrobbing(-1 );
return 0;
}
return animation_.GetCurrentValue();
}
void NetworkIconAnimation::AddObserver(AnimationObserver* observer) {
if (!observers_.HasObserver(observer))
observers_.AddObserver(observer);
}
void NetworkIconAnimation::RemoveObserver(AnimationObserver* observer) {
observers_.RemoveObserver(observer);
if (!observers_.might_have_observers())
animation_.Reset();
}
NetworkIconAnimation* NetworkIconAnimation::GetInstance() {
static NetworkIconAnimation* s_icon_animation =
new NetworkIconAnimation();
return s_icon_animation;
}
}
}