Esempio n. 1
0
 public static List<Game> loadGames(int gameKey, ContentResolver resolver, List<Long> timestamps) {
   List<Game> gamesToSend = new ArrayList<Game>(timestamps.size());
   switch (gameKey) {
     case GameKey.TICHU:
       try {
         gamesToSend =
             TichuGame.loadGames(
                 resolver, GameStorageHelper.getUriAllItems(gameKey), timestamps, false);
       } catch (CompactedDataCorruptException e) {
         assert false; // load games will not throw as requested by the parameter
       }
       break;
     case DOPPELKOPF:
       try {
         gamesToSend =
             DoppelkopfGame.loadGames(
                 resolver, GameStorageHelper.getUriAllItems(gameKey), timestamps, false);
       } catch (CompactedDataCorruptException e) {
         assert false; // load games will not throw as requested by the parameter
       }
       break;
     default:
       throw new IllegalArgumentException("Game not supported: " + gameKey);
   }
   return gamesToSend;
 }
Esempio n. 2
0
 public static int[] calculateUsedGames(ContentResolver resolver) {
   // all games were something is stored for
   LinkedList<Integer> used = new LinkedList<Integer>();
   for (int key : ALL_GAMES) {
     if (GameStorageHelper.getStoredGamesCount(resolver, key) > 0) {
       used.add(key);
     }
   }
   int[] data = new int[used.size()];
   int index = 0;
   for (int key : used) {
     data[index++] = key;
   }
   return data;
 }