Пример #1
0
 private void loadObfData(
     File mapPath,
     List<LocalIndexInfo> result,
     boolean backup,
     LoadLocalIndexTask loadTask,
     Map<String, String> loadedMaps) {
   if (mapPath.canRead()) {
     for (File mapFile : listFilesSorted(mapPath)) {
       if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
         LocalIndexType lt = LocalIndexType.MAP_DATA;
         if (mapFile.getName().endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)) {
           lt = LocalIndexType.SRTM_DATA;
         } else if (mapFile.getName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) {
           lt = LocalIndexType.WIKI_DATA;
         }
         LocalIndexInfo info = new LocalIndexInfo(lt, mapFile, backup);
         if (loadedMaps.containsKey(mapFile.getName()) && !backup) {
           info.setLoaded(true);
         }
         updateDescription(info);
         result.add(info);
         loadTask.loadFile(info);
       }
     }
   }
 }
Пример #2
0
  private void loadTilesData(
      File tilesPath, List<LocalIndexInfo> result, boolean backup, LoadLocalIndexTask loadTask) {
    if (tilesPath.canRead()) {
      for (File tileFile : listFilesSorted(tilesPath)) {
        if (tileFile.isFile() && tileFile.getName().endsWith(SQLiteTileSource.EXT)) {
          LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup);
          updateDescription(info);
          result.add(info);
          loadTask.loadFile(info);
        } else if (tileFile.isDirectory()) {
          LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup);

          if (!TileSourceManager.isTileSourceMetaInfoExist(tileFile)) {
            info.setCorrupted(true);
          }
          updateDescription(info);
          result.add(info);
          loadTask.loadFile(info);
        }
      }
    }
  }
Пример #3
0
 public void updateDescription(LocalIndexInfo info) {
   File f = new File(info.getPathToData());
   if (info.getType() == LocalIndexType.MAP_DATA) {
     Map<String, String> ifns = app.getResourceManager().getIndexFileNames();
     if (ifns.containsKey(info.getFileName())) {
       try {
         Date dt = app.getResourceManager().getDateFormat().parse(ifns.get(info.getFileName()));
         info.setDescription(getInstalledDate(dt.getTime(), null));
       } catch (ParseException e) {
         e.printStackTrace();
       }
     } else {
       info.setDescription(getInstalledDate(f));
     }
   } else if (info.getType() == LocalIndexType.TILES_DATA) {
     ITileSource template;
     if (f.isDirectory() && TileSourceManager.isTileSourceMetaInfoExist(f)) {
       template = TileSourceManager.createTileSourceTemplate(new File(info.getPathToData()));
     } else if (f.isFile() && f.getName().endsWith(SQLiteTileSource.EXT)) {
       template = new SQLiteTileSource(app, f, TileSourceManager.getKnownSourceTemplates());
     } else {
       return;
     }
     String descr = "";
     descr += app.getString(R.string.local_index_tile_data_name, template.getName());
     if (template.getExpirationTimeMinutes() >= 0) {
       descr +=
           "\n"
               + app.getString(
                   R.string.local_index_tile_data_expire, template.getExpirationTimeMinutes());
     }
     info.setDescription(descr);
   } else if (info.getType() == LocalIndexType.SRTM_DATA) {
     info.setDescription(app.getString(R.string.download_srtm_maps));
   } else if (info.getType() == LocalIndexType.WIKI_DATA) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.TTS_VOICE_DATA) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.DEACTIVATED) {
     info.setDescription(getInstalledDate(f));
   } else if (info.getType() == LocalIndexType.VOICE_DATA) {
     info.setDescription(getInstalledDate(f));
   }
 }