public Map<Long, Game> pingDownloadedGames() { if (downloadedStamp == null || AppUtils.getTimeDiff(downloadedStamp, new Date(), TimeUnit.SECONDS) > 10) { downloadedStamp = new Date(); // gen downloaded games List<Game> d_games = new ArrayList<>(); // NSMutableArray *d_games = [[NSMutableArray alloc] init]; // SBJsonParser *jsonParser = [[SBJsonParser alloc] init]; File appDir = new File(mGamePlayAct.getFilesDir().getPath()); // NSString *rootString = [_MODEL_ applicationDocumentsDirectory]; // get contents of directory File[] directoryContent = appDir.listFiles(); // NSArray *directoryContent = [[NSFileManager defaultManager] // contentsOfDirectoryAtPath:rootString error:NULL]; Gson gson = new Gson(); // loop through all game files in the directory for (File gameFile : directoryContent) { if (gameFile.isFile() && gameFile.getName().endsWith("_game.json")) { String jsonStoredGame = AppUtils.readFromFileStream( mGamePlayAct, gameFile); // read raw json from stored game file Game g = gson.fromJson(jsonStoredGame, Game.class); // deserialize json into Game if (!g.network_level.equalsIgnoreCase("REMOTE")) // condition added with 8/16 iOS update d_games.add(g); } } // send directly to updateDownloadedGames() (Android) if (d_games.size() > 0) this.updateDownloadedGames( d_games); // _ARIS_NOTIF_SEND_(@"SERVICES_DOWNLOADED_GAMES_RECEIVED", nil, // @{@"games":d_games}); // emulate 'services' for consistency's sake (iOS only) // if (d_games.size() > 0) // mGamePlayAct.mDispatch.services_downloaded_games_received(d_games); // // _ARIS_NOTIF_SEND_(@"SERVICES_DOWNLOADED_GAMES_RECEIVED", nil, @{@"games":d_games}); } mGamePlayAct.performSelector.postDelayed( new Runnable() { @Override public void run() { notifDownloadedGames(); } }, 1000); // delay 1000ms = 1sec // else [self performSelector:@selector(notifDownloadedGames) withObject:nil afterDelay:1]; return downloadedGames; }