Add a delegate callback for the activity indicator mode animation
MODIFY
components/ActivityIndicator/src/MDCActivityIndicator.h
components/ActivityIndicator/src/MDCActivityIndicator.h
@@ -131,4 +131,13 @@ IB_DESIGNABLE
*/
- (void)activityIndicatorAnimationDidFinish:(nonnull MDCActivityIndicator *)activityIndicator;
+/**
+ When setIndicatorMode:animated: is called the spinner animates the transition from the current
+ mode to the new mode. This method is called after the animation completes or immediately if no
+ animation is requested.
+
+ @param activityIndicator Caller
+ */
+- (void)activityIndicatorModeTransitionDidFinish:(nonnull MDCActivityIndicator *)activityIndicator;
+
@end

MODIFY
components/ActivityIndicator/src/MDCActivityIndicator.m
components/ActivityIndicator/src/MDCActivityIndicator.m
@@ -290,6 +290,10 @@ static const CGFloat kSingleCycleRotation =
[self addTransitionToIndeterminateCycle];
break;
}
+ } else {
+ if ([_delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
+ [_delegate activityIndicatorModeTransitionDidFinish:self];
+ }
}
}
@@ -516,6 +520,9 @@ static const CGFloat kSingleCycleRotation =
// Special case for 0% progress.
_cycleCount = nearestCycle;
[self strokeRotationCycleFinishedFromState:MDCActivityIndicatorStateTransitionToIndeterminate];
+ if ([_delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
+ [_delegate activityIndicatorModeTransitionDidFinish:self];
+ }
return;
}
@@ -542,6 +549,9 @@ static const CGFloat kSingleCycleRotation =
[CATransaction setCompletionBlock:^{
[self
strokeRotationCycleFinishedFromState:MDCActivityIndicatorStateTransitionToIndeterminate];
+ if ([_delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
+ [_delegate activityIndicatorModeTransitionDidFinish:self];
+ }
}];
[CATransaction setDisableActions:YES];
@@ -582,6 +592,9 @@ static const CGFloat kSingleCycleRotation =
_currentProgress = 0.0f;
_lastProgress = _currentProgress;
[self strokeRotationCycleFinishedFromState:MDCActivityIndicatorStateTransitionToDeterminate];
+ if ([_delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
+ [_delegate activityIndicatorModeTransitionDidFinish:self];
+ }
} else {
_currentProgress = MAX(_progress, _minStrokeDifference);
@@ -600,6 +613,9 @@ static const CGFloat kSingleCycleRotation =
[CATransaction setCompletionBlock:^{
[self
strokeRotationCycleFinishedFromState:MDCActivityIndicatorStateTransitionToDeterminate];
+ if ([_delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
+ [_delegate activityIndicatorModeTransitionDidFinish:self];
+ }
}];
[CATransaction setDisableActions:YES];
[CATransaction mdm_setTimeScaleFactor:@(duration)];

Add a delegate callback for the activity indicator mode animation (#2537)