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-23973] Fix event-issues in Ti.UI.ImageView #8461

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions iphone/Classes/TiUIImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ -(void)startTimerWithEvent:(NSString *)eventName
}
}

#ifdef TI_USE_KROLL_THREAD
-(void)listenerAdded:(NSString *)type count:(int)count
{
if (count == 1 && [type isEqualToString:@"load"]) {
NSString *loadEventState = [(TiUIImageViewProxy*)[self proxy] loadEventState];
if (loadEventState) {
[[self proxy] fireEvent:@"load" withObject:@{@"state": loadEventState}];
}
} else {
[super listenerAdded:type count:count];
}
}
#endif

-(void)stopTimerWithEvent:(NSString *)eventName
{
if (!stopped) {
Expand Down
6 changes: 5 additions & 1 deletion iphone/Classes/TiUIImageViewProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
#import "TiViewProxy.h"
#import "ImageLoader.h"

@interface TiUIImageViewProxy : TiViewProxy<ImageLoaderDelegate, TiProxyDelegate> {
@interface TiUIImageViewProxy : TiViewProxy<ImageLoaderDelegate> {
ImageLoaderRequest *urlRequest;
NSURL* imageURL;
}

@property (nonatomic,retain) NSURL* imageURL;
#ifdef TI_USE_KROLL_THREAD
@property (nonatomic, assign) NSString* loadEventState;
#endif

-(void)cancelPendingImageLoads;
-(void)startImageLoad:(NSURL *)url;
Expand Down
32 changes: 9 additions & 23 deletions iphone/Classes/TiUIImageViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#define DEBUG_IMAGEVIEW
#define DEFAULT_IMAGEVIEW_INTERVAL 200

@interface TiUIImageViewProxy ()
@property (nonatomic, copy) NSString* loadEventState;
@end

@implementation TiUIImageViewProxy
@synthesize imageURL, loadEventState;
@synthesize imageURL;

#ifdef TI_USE_KROLL_THREAD
@synthesize loadEventState;
#endif

static NSArray* imageKeySequence;

Expand Down Expand Up @@ -57,28 +57,12 @@ -(void)propagateLoadEvent:(NSString *)stateString
[self fireEvent:@"load" withObject:event];
#ifdef TI_USE_KROLL_THREAD
} else {
// Why do we do this?
// When running on kroll thread this is being called before the events are added.
// So we try to propagate this after the load event is added.
// TIMOB-20204
RELEASE_TO_NIL(self.loadEventState);
[self setLoadEventState:stateString];
[self setModelDelegate:self];
RELEASE_TO_NIL(loadEventState);
loadEventState = [stateString copy];
#endif
}
}

-(void)listenerAdded:(NSString*)type count:(int)count {
if ([self _hasListeners:@"load"]) {
[self setModelDelegate:nil];
[self fireEvent:@"load" withObject:@{@"state": [self loadEventState]}];
}
}

-(void)propertyChanged:(NSString*)key oldValue:(id)oldValue newValue:(id)newValue proxy:(TiProxy*)proxy {
DoProxyDelegateChangedValuesWithProxy((TiUIImageView*)[self view], key, oldValue, newValue, proxy);
}

-(void)_configure
{
[self replaceValue:NUMBOOL(NO) forKey:@"animating" notification:NO];
Expand Down Expand Up @@ -152,7 +136,9 @@ - (void) dealloc
[self replaceValue:nil forKey:@"image" notification:NO];

RELEASE_TO_NIL(imageURL);
#ifdef TI_USE_KROLL_THREAD
RELEASE_TO_NIL(loadEventState);
#endif
[super dealloc];
}

Expand Down