refactor: Improve code formatting
This commit is contained in:
@@ -202,105 +202,75 @@
|
||||
}
|
||||
|
||||
}
|
||||
- (IBAction)inviaMessaggio:(id)sender {
|
||||
|
||||
|
||||
- (IBAction)inviaMessaggio:(id)sender
|
||||
{
|
||||
if ([self.userDefoult objectForKey:CODE_MESSAGE_EQN]) {
|
||||
|
||||
NSDate *dateMessage = [self.userDefoult objectForKey:DATA_MESSAGE_EQN];
|
||||
if ([EQNUtility getDifferenceMinute:dateMessage] <= TEMPO_INVIO_MESSAGGIO){
|
||||
|
||||
UIAlertController *messaggio = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione ", @"") message:NSLocalizedString(@"Il messaggio è già stato in viato, al momento non è possibile inviare una nuova segnalazione", @"") preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
return ;
|
||||
}];
|
||||
|
||||
[messaggio addAction:defaultAction];
|
||||
[self presentViewController:messaggio animated:YES completion:nil];
|
||||
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione ", @"")
|
||||
message:NSLocalizedString(@"Il messaggio è già stato in viato, al momento non è possibile inviare una nuova segnalazione", @"")
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(sincronizzazione) withObject:nil waitUntilDone:YES];
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UIButton *button = (UIButton *)sender;
|
||||
CLGeocoder *geocoder = [CLGeocoder new];
|
||||
[geocoder reverseGeocodeLocation:[EQNUser defaultUser].lastPosition
|
||||
completionHandler:^(NSArray *placemarks, NSError *error) {
|
||||
|
||||
if (error) {
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
UIAlertController *errore = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione", @"") message:NSLocalizedString(@"La tua posizione geografica è sconosciuta e non è possibile segnalare il sisma", @"") preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
return ;
|
||||
}];
|
||||
|
||||
[errore addAction:defaultAction];
|
||||
[self presentViewController:errore animated:YES completion:nil];
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Check if any placemarks were found
|
||||
if (placemarks && placemarks.count > 0)
|
||||
{
|
||||
CLPlacemark *placemark = placemarks[0];
|
||||
// Dictionary containing address information
|
||||
// NSDictionary *addressDictionary = placemark.addressDictionary;
|
||||
|
||||
NSString *address = [NSString stringWithFormat:@"%@-%@", placemark.locality, placemark.country];
|
||||
|
||||
NSURL *url = [EQNGeneratoreURLServer urlInvioMessagioTerremoto:button.tag withAdress:address];
|
||||
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:segnalazzioneTerremoto success:^(id result) {
|
||||
|
||||
[self.userDefoult setObject:result forKey:CODE_MESSAGE_EQN];
|
||||
[self.userDefoult setObject:[NSDate date] forKey:DATA_MESSAGE_EQN];
|
||||
|
||||
UIAlertController *messaggio = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Segnalazione ", @"") message:NSLocalizedString(@"La tua segnalazione è stata inviata correttamente", @"") preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
return ;
|
||||
}];
|
||||
|
||||
[messaggio addAction:defaultAction];
|
||||
[self presentViewController:messaggio animated:YES completion:nil];
|
||||
|
||||
|
||||
[self performSelectorOnMainThread:@selector(sincronizzazione) withObject:nil waitUntilDone:YES];
|
||||
|
||||
} failure:^(NSError * error) {
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
|
||||
UIAlertController *errore = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione", @"") message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
return ;
|
||||
}];
|
||||
|
||||
[errore addAction:defaultAction];
|
||||
[self presentViewController:errore animated:YES completion:nil];
|
||||
|
||||
});
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
}];
|
||||
[geocoder reverseGeocodeLocation:[EQNUser defaultUser].lastPosition completionHandler:^(NSArray *placemarks, NSError *error) {
|
||||
if (error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione", @"")
|
||||
message:NSLocalizedString(@"La tua posizione geografica è sconosciuta e non è possibile segnalare il sisma", @"")
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if any placemarks were found
|
||||
if (placemarks && placemarks.count > 0)
|
||||
{
|
||||
CLPlacemark *placemark = placemarks[0];
|
||||
// Dictionary containing address information
|
||||
// NSDictionary *addressDictionary = placemark.addressDictionary;
|
||||
|
||||
NSString *address = [NSString stringWithFormat:@"%@-%@", placemark.locality, placemark.country];
|
||||
|
||||
NSURL *url = [EQNGeneratoreURLServer urlInvioMessagioTerremoto:button.tag withAdress:address];
|
||||
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:segnalazzioneTerremoto success:^(id result) {
|
||||
|
||||
[self.userDefoult setObject:result forKey:CODE_MESSAGE_EQN];
|
||||
[self.userDefoult setObject:[NSDate date] forKey:DATA_MESSAGE_EQN];
|
||||
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Segnalazione ", @"")
|
||||
message:NSLocalizedString(@"La tua segnalazione è stata inviata correttamente", @"")
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(sincronizzazione) withObject:nil waitUntilDone:YES];
|
||||
} failure:^(NSError * error) {
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione", @"")
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
});
|
||||
}];
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user