Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some re-factoring to support migrating to T3ImageView in Facebook

  • Loading branch information...
commit 37a2ad2b4ae750d053f972523dc1e6c3d87ecc12 1 parent 756ccb8
@joehewitt joehewitt authored
View
4 src/T3ImageView.m
@@ -71,10 +71,6 @@ - (void)request:(T3URLRequest*)request loadedData:(NSData*)data media:(id)media
if ([media isKindOfClass:[UIImage class]]) {
self.image = (UIImage*)media;
-
- if ([_delegate respondsToSelector:@selector(imageViewLoaded:)]) {
- [_delegate imageViewLoaded:self];
- }
} else {
if ([_delegate respondsToSelector:@selector(imageView:loadDidFailWithError:)]) {
[_delegate imageView:self loadDidFailWithError:nil];
View
2  src/T3URLCache.m
@@ -601,7 +601,7 @@ - (void)storeData:(NSData*)data media:(id)media forURL:(NSString*)url toDisk:(BO
}
}
-- (NSString*)storeDataWithTemporaryURL:(NSData*)data media:(id)media toDisk:(BOOL)toDisk {
+- (NSString*)storeTemporaryData:(NSData*)data media:(id)media toDisk:(BOOL)toDisk {
static int temporaryURLIncrement = 0;
NSString* url = [NSString stringWithFormat:@"temp:%d", temporaryURLIncrement++];
View
7 src/T3URLRequest.m
@@ -5,7 +5,7 @@
@implementation T3URLRequest
-@synthesize url, delegate, cache, minTime, convertMedia;
+@synthesize url, delegate, minTime, convertMedia;
+ (T3URLRequest*)requestWithURL:(NSString*)url delegate:(id<T3URLRequestDelegate>)aDelegate {
return [[[T3URLRequest alloc] initWithURL:url delegate:aDelegate] autorelease];
@@ -15,7 +15,6 @@ - (id)initWithURL:(NSString*)aURL delegate:(id<T3URLRequestDelegate>)aDelegate {
if (self = [super init]) {
url = [aURL retain];
delegate = aDelegate;
- cache = [T3URLCache sharedCache];
convertMedia = NO;
minTime = T3_DEFAULT_CACHE_AGE;
}
@@ -28,11 +27,11 @@ - (void)dealloc {
}
- (BOOL)send {
- return [cache sendRequest:self];
+ return [[T3URLCache sharedCache] sendRequest:self];
}
- (void)cancel {
- [cache cancelRequest:self];
+ [[T3URLCache sharedCache] cancelRequest:self];
}
@end
View
1  src/Three20/T3ImageView.h
@@ -28,7 +28,6 @@
@optional
- (void)imageViewPosted:(T3ImageView*)imageView;
- (void)imageViewLoading:(T3ImageView*)imageView;
-- (void)imageViewLoaded:(T3ImageView*)imageView;
- (void)imageView:(T3ImageView*)imageView loadDidFailWithError:(NSError*)error;
@end
View
2  src/Three20/T3URLCache.h
@@ -118,7 +118,7 @@
*
* @return The temporary URL
*/
-- (NSString*)storeDataWithTemporaryURL:(NSData*)data media:(id)media toDisk:(BOOL)toDisk;
+- (NSString*)storeTemporaryData:(NSData*)data media:(id)media toDisk:(BOOL)toDisk;
/**
* Moves the data currently stored under one URL to another URL.
View
41 src/Three20/T3URLRequest.h
@@ -1,19 +1,17 @@
#import "Three20/T3Global.h"
-@class T3URLCache;
@protocol T3URLRequestDelegate;
+@class T3URLCache;
@interface T3URLRequest : NSObject {
NSString* url;
id<T3URLRequestDelegate> delegate;
- T3URLCache* cache;
NSTimeInterval minTime;
BOOL convertMedia;
}
-@property(nonatomic,readonly) NSString* url;
@property(nonatomic,readonly) id<T3URLRequestDelegate> delegate;
-@property(nonatomic,assign) T3URLCache* cache;
+@property(nonatomic,readonly) NSString* url;
@property(nonatomic) NSTimeInterval minTime;
@property(nonatomic) BOOL convertMedia;
@@ -22,10 +20,21 @@
- (id)initWithURL:(NSString*)url delegate:(id<T3URLRequestDelegate>)delegate;
/**
+ * Attempts to send a request.
+ *
+ * If the request can be resolved by the cache, it will happen synchronously. Otherwise,
+ * the request will respond to its delegate asynchronously.
+ *
* @return YES if the request was loaded synchronously from the cache.
*/
- (BOOL)send;
+/**
+ * Cancels the request.
+ *
+ * If there are multiple requests going to the same URL as this request, the others will
+ * not be cancelled.
+ */
- (void)cancel;
@end
@@ -33,10 +42,34 @@
@protocol T3URLRequestDelegate <NSObject>
@optional
+
+/**
+ * The request has been posted but not necessarily sent to the network yet.
+ *
+ * If the request is served from the cache, this method will not be called.
+ */
- (void)requestPosted:(T3URLRequest*)request;
+
+/**
+ * The request has connected to the server and loading has begun.
+ */
- (void)requestLoading:(T3URLRequest*)request;
+
+/**
+ * The request has loaded data and optionally converted it to a media object.
+ *
+ * If the request is served from the cache, the is the only delegate method that will be called.
+ */
- (void)request:(T3URLRequest*)request loadedData:(NSData*)data media:(id)media;
+
+/**
+ *
+ */
- (void)request:(T3URLRequest*)request didFailWithError:(NSError*)error;
+
+/**
+ *
+ */
- (void)requestCancelled:(T3URLRequest*)request;
@end
View
2  src/Three20/Three20.h
@@ -15,4 +15,4 @@
#import "Three20/T3ActivityLabel.h"
#import "Three20/T3ShinyLabel.h"
#import "Three20/T3YouTubeView.h"
-#import "Three20/T3PaintedView.h"
+#import "Three20/T3BackgroundView.h"
Please sign in to comment.
Something went wrong with that request. Please try again.