daily pastebin goal
3%
SHARE
TWEET

Untitled

DontPanic284 May 16th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)updateRoundAndTimeServer:(NSNumber*)shouldRequestTimeServerObject
  2. {
  3.     //ko gọi lặp service
  4.     if(g_isSynchronizeData)
  5.         return;
  6.  
  7.     g_isSynchronizeData = YES;
  8.  
  9.     BOOL shouldRequestTimeServer = [shouldRequestTimeServerObject boolValue];
  10.  
  11.     [[ATMAPIManager sharedManager] callAPIgetListRoundsLimit:1 typeData:0 showIndicator:YES onSuccess:^(NSDictionary *response) {
  12.         if ([response[@"data"] isKindOfClass:[NSArray class]]) {
  13.             NSArray *array = response[@"data"];
  14.             if (array.count) {
  15.                 NSDictionary *round = array[0];
  16.                 ATMRound *roundData = [[ATMRound alloc]init];
  17.                 [roundData setInfo:round];
  18.                 [[InUseShareManager sharedManager] synchronizeNextRound:roundData completionHandler:^(NSString *error) {
  19.                     if (shouldRequestTimeServer)
  20.                     {
  21.                         _numRetryGetServerTime = 0;
  22.                         [self callAPIGetServerTimeWithFirstOpenState:[NSNumber numberWithBool:NO]];
  23.                     }
  24.                     else
  25.                     {
  26.                         //trường hợp ko lấy time server thì phải tạo local notification
  27.                         [[InUseShareManager sharedManager] addLocalNotification];
  28.                         //update schedule (ko lấy time server tức là đang ở trong app và kết thúc vòng đấu)
  29.                         [[NSNotificationCenter defaultCenter] postNotificationName:UPDATE_SCHEDULE object:nil];
  30.  
  31.                         g_isSynchronizeData = NO;
  32.                     }
  33.                 }];                
  34.             }
  35.             else
  36.             {
  37.                 [self performSelector:@selector(updateRoundAndTimeServer:) withObject:shouldRequestTimeServerObject afterDelay:0.5];
  38.             }
  39.         }
  40.         else
  41.         {
  42.             [self performSelector:@selector(updateRoundAndTimeServer:) withObject:shouldRequestTimeServerObject afterDelay:0.5];
  43.         }
  44.     } onError:^(NSError *error) {
  45.         [self performSelector:@selector(updateRoundAndTimeServer:) withObject:shouldRequestTimeServerObject afterDelay:0.5];
  46.     }];
  47. }
RAW Paste Data
Top