From 0e15b67c86be0229b730885e19600f4768be2569 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 22 Mar 2011 22:24:37 -0700 Subject: [PATCH] Add reachability to Refresh button. --- MobileCydia.mm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index 8eeb8575..a85c12e4 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -7690,9 +7690,29 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi return path; } +- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button { + NSString *context([alert context]); + + if ([context isEqualToString:@"norefresh"]) + [alert dismissWithClickedButtonIndex:-1 animated:YES]; +} + - (void) refreshButtonClicked { - [delegate_ beginUpdate]; - [[self navigationItem] setLeftBarButtonItem:nil animated:YES]; + if (IsReachable("cydia.saurik.com")) { + [delegate_ beginUpdate]; + [[self navigationItem] setLeftBarButtonItem:nil animated:YES]; + } else { + UIAlertView *alert = [[[UIAlertView alloc] + initWithTitle:[NSString stringWithFormat:Colon_, Error_, UCLocalize("REFRESH")] + message:@"Host Unreachable" // XXX: Localize + delegate:self + cancelButtonTitle:UCLocalize("OK") + otherButtonTitles:nil + ] autorelease]; + + [alert setContext:@"norefresh"]; + [alert show]; + } } - (void) upgradeButtonClicked { -- 2.45.2