-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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-13000] Fixed load event on image view #4996
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
#import "TiLocale.h" | ||
#import "TiUIView.h" | ||
#import "TiApp.h" | ||
#import "TiUIImageViewProxy.h" | ||
|
||
#import <QuartzCore/QuartzCore.h> | ||
#import <libkern/OSAtomic.h> | ||
|
@@ -1617,8 +1618,17 @@ -(BOOL)_hasListeners:(NSString *)type | |
return [self _hasListeners:type checkParent:YES]; | ||
} | ||
|
||
//TODO: Remove once we've properly deprecated. | ||
-(void)fireEvent:(NSString*)type withObject:(id)obj withSource:(id)source propagate:(BOOL)propagate reportSuccess:(BOOL)report errorCode:(int)code message:(NSString*)message; | ||
-(NSArray *)stateEvents | ||
{ | ||
NSMutableArray *arr = [NSMutableArray array]; | ||
[arr addObject:@"postlayout"]; | ||
if([self isKindOfClass:[TiUIImageViewProxy class]]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check should not be here. Instead the TiUIImageViewProxy class must override the method to return a different array |
||
[arr addObject:@"load"]; | ||
} | ||
return arr; | ||
} | ||
|
||
-(BOOL)viewProxyShouldFireEvent:(NSString *)type | ||
{ | ||
// Note that some events (like movie 'complete') are fired after the view is removed/dealloc'd. | ||
// Because of the handling below, we can safely set the view to 'nil' in this case. | ||
|
@@ -1631,25 +1641,20 @@ -(void)fireEvent:(NSString*)type withObject:(id)obj withSource:(id)source propag | |
// Have to handle the situation in which the proxy's view might be nil... like, for example, | ||
// with table rows. Automagically assume any nil view we're firing an event for is A-OK. | ||
// NOTE: We want to fire postlayout events on ANY view, even those which do not allow interactions. | ||
if (proxyView == nil || [proxyView interactionEnabled] || [type isEqualToString:@"postlayout"]) { | ||
return (proxyView == nil || [proxyView interactionEnabled] || [[self stateEvents] containsObject:type]); | ||
} | ||
|
||
//TODO: Remove once we've properly deprecated. | ||
-(void)fireEvent:(NSString*)type withObject:(id)obj withSource:(id)source propagate:(BOOL)propagate reportSuccess:(BOOL)report errorCode:(int)code message:(NSString*)message; | ||
{ | ||
if ([self viewProxyShouldFireEvent:type]) { | ||
[super fireEvent:type withObject:obj withSource:source propagate:propagate reportSuccess:report errorCode:code message:message]; | ||
} | ||
} | ||
|
||
-(void)fireEvent:(NSString*)type withObject:(id)obj propagate:(BOOL)propagate reportSuccess:(BOOL)report errorCode:(int)code message:(NSString*)message; | ||
{ | ||
// Note that some events (like movie 'complete') are fired after the view is removed/dealloc'd. | ||
// Because of the handling below, we can safely set the view to 'nil' in this case. | ||
TiUIView* proxyView = [self viewAttached] ? view : nil; | ||
//TODO: We have to do view instead of [self view] because of a freaky race condition that can | ||
//happen in the background (See bug 2809). This assumes that view == [self view], which may | ||
//not always be the case in the future. Then again, we shouldn't be dealing with view in the BG... | ||
|
||
|
||
// Have to handle the situation in which the proxy's view might be nil... like, for example, | ||
// with table rows. Automagically assume any nil view we're firing an event for is A-OK. | ||
// NOTE: We want to fire postlayout events on ANY view, even those which do not allow interactions. | ||
if (proxyView == nil || [proxyView interactionEnabled] || [type isEqualToString:@"postlayout"]) { | ||
if ([self viewProxyShouldFireEvent:type]) { | ||
if (eventOverrideDelegate != nil) { | ||
obj = [eventOverrideDelegate overrideEventObject:obj forEvent:type fromViewProxy:self]; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole method is extremely inefficient. It essentially returns an autoreleased array every time it is invoked. You should initialize the array once. Easiest to initialize in the init method of the proxy. You can define a protected NSArray in TiViewProxy interface and initialize it accordingly in various proxies