if (title_ != nil)
[title_ release];
+ if ([loading_ count] != 0)
+ [delegate_ releaseNetworkActivityIndicator];
[loading_ release];
[reloaditem_ release];
if ([scheme isEqualToString:@"mailto"])
[self _openMailToURL:url];
- CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
+ CYViewController *page([delegate_ pageForURL:url]);
if (page == nil) {
BrowserController *browser([[[class_ alloc] init] autorelease]);
[[self navigationController] pushViewController:page animated:YES];
} else {
- UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
+ UCNavigationController *navigation([[[UCNavigationController alloc] initWithRootViewController:page] autorelease]);
[navigation setHook:indirect_];
[navigation setDelegate:delegate_];
- [navigation setViewControllers:[NSArray arrayWithObject:page]];
-
[[page navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("CLOSE")
style:UIBarButtonItemStylePlain
[alert dismissWithClickedButtonIndex:-1 animated:YES];
} else if ([context isEqualToString:@"submit"]) {
- switch (button) {
- case 1:
- break;
-
- case 2:
- if (request_ != nil) {
- WebThreadLock();
- [webview_ loadRequest:request_];
- WebThreadUnlock();
- }
- break;
-
- _nodefault
+ if (button == [alert cancelButtonIndex]) {
+ } else if (button == [alert firstOtherButtonIndex]) {
+ if (request_ != nil) {
+ WebThreadLock();
+ [webview_ loadRequest:request_];
+ WebThreadUnlock();
+ }
}
[alert dismissWithClickedButtonIndex:-1 animated:YES];
[[self navigationItem] setTitle:UCLocalize("LOADING")];
}
+- (void) layoutRightButton {
+ [[loadingitem_ view] addSubview:indicator_];
+ [[loadingitem_ view] bringSubviewToFront:indicator_];
+}
+
- (void) applyRightButton {
if ([self isLoading]) {
[[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
- // XXX: why do we do this again here? (if we don't, just remove indicator_)
- [[loadingitem_ view] addSubview:indicator_];
+ [self performSelector:@selector(layoutRightButton) withObject:nil afterDelay:0];
+
+ [indicator_ startAnimating];
[self applyLoadingTitle];
- } else if (custom_ != nil) {
- [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
} else {
- [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
+ [indicator_ stopAnimating];
+
+ [[self navigationItem] setRightBarButtonItem:(
+ custom_ != nil ? [self customButton] : [self rightButton]
+ ) animated:YES];
}
}
+- (void) didStartLoading {
+ // Overridden in subclasses.
+}
+
- (void) _didStartLoading {
[self applyRightButton];
+
+ if ([loading_ count] != 1)
+ return;
+
+ [delegate_ retainNetworkActivityIndicator];
+ [self didStartLoading];
+}
+
+- (void) didFinishLoading {
+ // Overridden in subclasses.
}
- (void) _didFinishLoading {
return;
[self applyRightButton];
+ [[self navigationItem] setTitle:title_];
- // XXX: wtf?
- if (![self isLoading])
- [[self navigationItem] setTitle:title_];
+ [delegate_ releaseNetworkActivityIndicator];
+ [self didFinishLoading];
}
- (bool) isLoading {
action:@selector(reloadButtonClicked)
];
- CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
- indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
- [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
- [indicator_ startAnimation];
- [[loadingitem_ view] addSubview:indicator_];
+ indicator_ = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
+ [indicator_ setFrame:CGRectMake(15, 5, [indicator_ frame].size.width, [indicator_ frame].size.height)];
[webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];