Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17572] iOS: Fix activity indicator animation in list items #9717

Merged
merged 6 commits into from
Jan 23, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions iphone/Classes/TiUIListItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#import "TiUtils.h"
#import "TiViewProxy.h"
#import "Webcolor.h"
#ifdef USE_TI_UIACTIVITYINDICATOR
#import "TiUIActivityIndicator.h"
#endif

@implementation TiUIListItem {
TiUIListItemProxy *_proxy;
Expand Down Expand Up @@ -91,6 +94,21 @@ - (void)prepareForReuse
{
RELEASE_TO_NIL(_dataItem);
[super prepareForReuse];

#ifdef USE_TI_UIACTIVITYINDICATOR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this issue not in TiUITableView ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was only described in Ti.UI.ListView because the developer can re-animate the indicator inside the Ti.UI.TableView as it's children are not hold virtually. As I didn't see any comparable issue on JIRA, I only made it for this one for now (and because we recommend to use Ti.UI.ListView for performant usages).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey.

// TIMOB-17572: Attempt to resume activity indicator animation to reuse cell
// Use this workaroud until iOS is smart enough to retain the animation state itself
if (self.subviews.firstObject != nil) {
UIView *container = self.subviews.firstObject;
[[container subviews] enumerateObjectsUsingBlock:^(__kindof UIView *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) {
if ([obj isKindOfClass:[TiUIActivityIndicator class]]) {
UIActivityIndicatorView *activityIndicator = [(TiUIActivityIndicator *)obj indicatorView];
[activityIndicator startAnimating];
*stop = YES;
}
}];
}
#endif
}

- (void)layoutSubviews
Expand Down