Skip to content

Commit

Permalink
[TIMOB-20204] iOS: ListView - onload events of template items not fired
Browse files Browse the repository at this point in the history
  • Loading branch information
sriks committed Mar 30, 2016
1 parent 0316839 commit a2ce6d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIImageViewProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "TiViewProxy.h"
#import "ImageLoader.h"

@interface TiUIImageViewProxy : TiViewProxy<ImageLoaderDelegate> {
@interface TiUIImageViewProxy : TiViewProxy<ImageLoaderDelegate, TiProxyDelegate> {
ImageLoaderRequest *urlRequest;
NSURL* imageURL;
}
Expand Down
32 changes: 30 additions & 2 deletions iphone/Classes/TiUIImageViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
#define DEBUG_IMAGEVIEW
#define DEFAULT_IMAGEVIEW_INTERVAL 200

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

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

static NSArray* imageKeySequence;

Expand Down Expand Up @@ -47,10 +51,33 @@ -(void)propagateLoadEvent:(NSString *)stateString
[self willChangeSize];
}
#endif

if ([self _hasListeners:@"load"]) {
NSDictionary *event = [NSDictionary dictionaryWithObject:stateString forKey:@"state"];
[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];
}
#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 {
// left blank intentionally.
}

-(void)_configure
Expand Down Expand Up @@ -126,7 +153,8 @@ - (void) dealloc
[self replaceValue:nil forKey:@"image" notification:NO];

RELEASE_TO_NIL(imageURL);
[super dealloc];
RELEASE_TO_NIL(loadEventState);
[super dealloc];
}

-(id)toBlob:(id)args
Expand Down

0 comments on commit a2ce6d1

Please sign in to comment.