mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
constant view tags.
move header constant to environment. move setting/clearing of user token header to user model.
This commit is contained in:
@@ -9,37 +9,40 @@
|
||||
#import "UIViewController+RKLoading.h"
|
||||
#import <Three20/Three20.h>
|
||||
|
||||
static NSInteger const kOverlayViewTag = 66;
|
||||
static NSInteger const kProgressViewTag = 67;
|
||||
|
||||
@implementation UIViewController (RKLoading)
|
||||
|
||||
- (void)requestDidStartLoad:(RKRequest*)request {
|
||||
UIView* overlayView = [self.view viewWithTag:66]; // TODO: Need constant for tags...
|
||||
UIView* overlayView = [self.view viewWithTag:kOverlayViewTag]; // TODO: Need constant for tags...
|
||||
if (overlayView == nil) {
|
||||
overlayView = [[TTActivityLabel alloc] initWithFrame:self.view.bounds style:TTActivityLabelStyleBlackBox text:@"Loading..."];
|
||||
overlayView.backgroundColor = [UIColor blackColor];
|
||||
overlayView.alpha = 0.5;
|
||||
overlayView.tag = 66;
|
||||
overlayView.tag = kOverlayViewTag;
|
||||
|
||||
[self.view addSubview:overlayView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)request:(RKRequest*)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
|
||||
UIProgressView* progressView = (UIProgressView*)[self.view viewWithTag:67];
|
||||
UIProgressView* progressView = (UIProgressView*)[self.view viewWithTag:kProgressViewTag];
|
||||
if (progressView == nil) {
|
||||
if (totalBytesWritten >= totalBytesExpectedToWrite) {
|
||||
// Uploaded all data at once. don't need a progress bar.
|
||||
return;
|
||||
}
|
||||
progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(10, 100, 300, 20)];
|
||||
progressView.tag = 67; // TODO: Need constant for tags...
|
||||
progressView.tag = kProgressViewTag;
|
||||
[self.view addSubview:progressView];
|
||||
}
|
||||
progressView.progress = totalBytesWritten / (float)totalBytesExpectedToWrite;
|
||||
}
|
||||
|
||||
- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {
|
||||
UIView* overlayView = [self.view viewWithTag:66]; // TODO: Need constant for tags...
|
||||
UIView* progressView = [self.view viewWithTag:67];
|
||||
UIView* overlayView = [self.view viewWithTag:kOverlayViewTag];
|
||||
UIView* progressView = [self.view viewWithTag:kProgressViewTag];
|
||||
[overlayView removeFromSuperview];
|
||||
[overlayView release];
|
||||
[progressView removeFromSuperview];
|
||||
|
||||
Reference in New Issue
Block a user