Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Merge commit 'joehewitt/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
verveguy committed Jun 17, 2009
2 parents 0c64eb5 + 4e34a0e commit 9ae5679
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/TTImageView.m
Expand Up @@ -33,6 +33,10 @@ - (void)display {
}
}

- (void)dealloc {
[super dealloc];
}

@end

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions src/TTNavigationCenter.m
Expand Up @@ -66,6 +66,10 @@ - (id)initWithClass:(Class)controllerClass rule:(TTNavigationRule)rule nib:(NSSt
return self;
}

- (void)dealloc {
[super dealloc];
}

@end

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions src/TTSearchTextField.m
Expand Up @@ -34,6 +34,10 @@ - (id)initWithTextField:(TTSearchTextField*)textField {
return self;
}

- (void)dealloc {
[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// UITextFieldDelegate

Expand Down
1 change: 1 addition & 0 deletions src/TTSearchlightLabel.m
Expand Up @@ -140,6 +140,7 @@ - (void)stopAnimating {
_timer = nil;
[self releaseMask];
}
[self setNeedsDisplay];
}

@end
9 changes: 9 additions & 0 deletions src/TTStyle.m
Expand Up @@ -207,6 +207,15 @@ + (TTPartStyle*)styleWithName:(NSString*)name style:(TTStyle*)stylez next:(TTSty
return style;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject

- (void)dealloc {
[_name release];
[_style release];
[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// TTStyle

Expand Down
5 changes: 5 additions & 0 deletions src/TTStyledFrame.m
Expand Up @@ -184,6 +184,10 @@ - (id)init {
return self;
}

- (void)dealloc {
[super dealloc];
}

- (TTStyledInlineFrame*)inlineParentFrame {
if ([_parentFrame isKindOfClass:[TTStyledInlineFrame class]]) {
return (TTStyledInlineFrame*)_parentFrame;
Expand Down Expand Up @@ -244,6 +248,7 @@ - (id)initWithElement:(TTStyledElement*)element node:(TTStyledImageNode*)node {
}

- (void)dealloc {
[_style release];
[super dealloc];
}

Expand Down
1 change: 1 addition & 0 deletions src/TTStyledNode.m
Expand Up @@ -478,6 +478,7 @@ - (id)init {
- (void)dealloc {
[_url release];
[_image release];
[_defaultImage release];
[super dealloc];
}

Expand Down
7 changes: 6 additions & 1 deletion src/TTTabBar.m
Expand Up @@ -9,6 +9,7 @@

static CGFloat kTabMargin = 10;
static CGFloat kPadding = 10;
static const NSInteger kMaxBadgeNumber = 99;

///////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -435,7 +436,11 @@ - (void)updateBadgeNumber {
_badge.userInteractionEnabled = NO;
[self addSubview:_badge];
}
_badge.text = [NSString stringWithFormat:@"%d", _tabItem.badgeNumber];
if (_tabItem.badgeNumber <= kMaxBadgeNumber) {
_badge.text = [NSString stringWithFormat:@"%d", _tabItem.badgeNumber];
} else {
_badge.text = [NSString stringWithFormat:@"%d+", kMaxBadgeNumber];
}
[_badge sizeToFit];

_badge.frame = CGRectMake(self.width - _badge.width-1, 1, _badge.width, _badge.height);
Expand Down
4 changes: 3 additions & 1 deletion src/TTTableField.m
Expand Up @@ -168,12 +168,13 @@ - (void)dealloc {

@implementation TTImageTableField

@synthesize defaultImage = _defaultImage, image = _image;
@synthesize defaultImage = _defaultImage, image = _image, imageStyle = _imageStyle;

- (id)init {
if (self = [super init]) {
_defaultImage = nil;
_image = nil;
_imageStyle = nil;
}
return self;
}
Expand All @@ -194,6 +195,7 @@ - (id)initWithText:(NSString*)text url:(NSString*)url image:(NSString*)image {
- (void)dealloc {
[_image release];
[_defaultImage release];
[_imageStyle release];
[super dealloc];
}

Expand Down
34 changes: 24 additions & 10 deletions src/TTTableFieldCell.m
Expand Up @@ -609,19 +609,32 @@ - (void)layoutSubviews {
image = field.defaultImage;
}
if (_iconView.url) {
CGFloat iconWidth = image
? image.size.width
: (field.image ? kDefaultIconSize : 0);
CGFloat iconHeight = image
? image.size.height
: (field.image ? kDefaultIconSize : 0);
CGFloat iconWidth = image
? image.size.width
: (field.image ? kDefaultIconSize : 0);
CGFloat iconHeight = image
? image.size.height
: (field.image ? kDefaultIconSize : 0);

TTImageStyle* style = [field.imageStyle firstStyleOfClass:[TTImageStyle class]];
if (style) {
_iconView.contentMode = style.contentMode;
_iconView.clipsToBounds = YES;
_iconView.backgroundColor = [UIColor clearColor];
if (style.size.width) {
iconWidth = style.size.width;
}
if (style.size.height) {
iconWidth = style.size.height;
}
}

_iconView.frame = CGRectMake(kHPadding, floor(self.height/2 - iconHeight/2),
iconWidth, iconHeight);

CGFloat innerWidth = self.contentView.width - (kHPadding*2 + iconWidth + kKeySpacing);
iconWidth, iconHeight);
CGFloat innerWidth = self.contentView.width - (kHPadding*2 + _iconView.width + kKeySpacing);
CGFloat innerHeight = self.contentView.height - kVPadding*2;
_label.frame = CGRectMake(kHPadding + iconWidth + kKeySpacing, kVPadding,
_label.frame = CGRectMake(kHPadding + _iconView.width + kKeySpacing, kVPadding,
innerWidth, innerHeight);
} else {
_label.frame = CGRectInset(self.contentView.bounds, kHPadding, kVPadding);
Expand All @@ -639,6 +652,7 @@ - (void)setObject:(id)object {
TTImageTableField* field = object;
_iconView.defaultImage = field.defaultImage;
_iconView.url = field.image;
_iconView.style = field.imageStyle;
}
}
@end
Expand Down
8 changes: 8 additions & 0 deletions src/TTTableViewController.m
Expand Up @@ -62,6 +62,10 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

- (void)dealloc {
[_tableDelegate release];
[_dataSource release];
_dataSource = nil;
[_tableView release];
_tableView = nil;
[super dealloc];
}

Expand Down Expand Up @@ -279,6 +283,10 @@ - (void)setDataSource:(id<TTTableViewDataSource>)dataSource {
- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
}

- (BOOL)shouldNavigateToURL:(NSString*)url {
return YES;
}

- (void)didBeginDragging {
}

Expand Down
6 changes: 5 additions & 1 deletion src/TTTableViewDelegate.m
Expand Up @@ -30,6 +30,10 @@ - (id)initWithController:(TTTableViewController*)controller {
return self;
}

- (void)dealloc {
[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// UITableViewDelegate

Expand All @@ -51,7 +55,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)
id object = [dataSource tableView:tableView objectForRowAtIndexPath:indexPath];
if ([object isKindOfClass:[TTTableField class]]) {
TTTableField* field = object;
if (field.url) {
if (field.url && [_controller shouldNavigateToURL:field.url]) {
[[TTNavigationCenter defaultCenter] displayURL:field.url];
}

Expand Down
4 changes: 4 additions & 0 deletions src/TTTextEditor.m
Expand Up @@ -33,6 +33,10 @@ - (id)initWithTextEditor:(TTTextEditor*)textEditor {
return self;
}

- (void)dealloc {
[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// UITextViewDelegate

Expand Down
18 changes: 11 additions & 7 deletions src/TTURLRequestQueue.m
Expand Up @@ -271,6 +271,7 @@ - (BOOL)cancel:(TTURLRequest*)request {
if (_connection) {
TTNetworkRequestStopped();
[_connection cancel];
[_connection release];
_connection = nil;
}
return NO;
Expand Down Expand Up @@ -433,6 +434,8 @@ - (void)executeLoader:(TTRequestLoader*)loader {
expires:loader.cacheExpirationAge
fromDisk:loader.cachePolicy & TTURLRequestCachePolicyDisk
data:&data error:&error timestamp:&timestamp]) {
[_loaders removeObjectForKey:loader.cacheKey];

if (!error) {
error = [loader processResponse:nil data:data];
}
Expand All @@ -441,8 +444,6 @@ - (void)executeLoader:(TTRequestLoader*)loader {
} else {
[loader dispatchLoaded:timestamp];
}

[_loaders removeObjectForKey:loader.cacheKey];
} else {
++_totalLoading;
[loader load:[NSURL URLWithString:loader.url]];
Expand Down Expand Up @@ -474,14 +475,15 @@ - (void)loadNextInQueue {
}
}

- (void)loadNextInQueueAfterLoader:(TTRequestLoader*)loader {
- (void)removeLoader:(TTRequestLoader*)loader {
--_totalLoading;
[_loaders removeObjectForKey:loader.cacheKey];
[self loadNextInQueue];
}

- (void)loader:(TTRequestLoader*)loader didLoadResponse:(NSHTTPURLResponse*)response
data:(id)data {
[self removeLoader:loader];

NSError* error = [loader processResponse:response data:data];
if (error) {
[loader dispatchError:error];
Expand All @@ -492,17 +494,19 @@ - (void)loader:(TTRequestLoader*)loader didLoadResponse:(NSHTTPURLResponse*)resp
[loader dispatchLoaded:[NSDate date]];
}

[self loadNextInQueueAfterLoader:loader];
[self loadNextInQueue];
}

- (void)loader:(TTRequestLoader*)loader didFailLoadWithError:(NSError*)error {
[self removeLoader:loader];
[loader dispatchError:error];
[self loadNextInQueueAfterLoader:loader];
[self loadNextInQueue];
}

- (void)loaderDidCancel:(TTRequestLoader*)loader wasLoading:(BOOL)wasLoading {
if (wasLoading) {
[self loadNextInQueueAfterLoader:loader];
[self removeLoader:loader];
[self loadNextInQueue];
} else {
[_loaders removeObjectForKey:loader.cacheKey];
}
Expand Down
4 changes: 3 additions & 1 deletion src/Three20/TTTableField.h
@@ -1,6 +1,6 @@
#import "Three20/TTGlobal.h"

@class TTStyledText;
@class TTStyledText, TTStyle;

@interface TTTableField : NSObject {
NSString* _text;
Expand Down Expand Up @@ -82,10 +82,12 @@
@interface TTImageTableField : TTTableField {
UIImage* _defaultImage;
NSString* _image;
TTStyle* _imageStyle;
}

@property(nonatomic,retain) UIImage* defaultImage;
@property(nonatomic,copy) NSString* image;
@property(nonatomic,retain) TTStyle* imageStyle;

- (id)initWithText:(NSString*)text url:(NSString*)url image:(NSString*)image;

Expand Down
1 change: 1 addition & 0 deletions src/Three20/TTTableViewController.h
Expand Up @@ -20,6 +20,7 @@
- (id<UITableViewDelegate>)createDelegate;

- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath;
- (BOOL)shouldNavigateToURL:(NSString*)url;

- (void)didBeginDragging;
- (void)didEndDragging;
Expand Down
5 changes: 5 additions & 0 deletions src/UIViewAdditions.m
Expand Up @@ -26,6 +26,11 @@ @interface UIEventFake : NSObject {
@end

@implementation UIEventFake

- (void)dealloc {
[super dealloc];
}

@end

@interface UITouch (TTCategory)
Expand Down

0 comments on commit 9ae5679

Please sign in to comment.