Пример #1
0
 private static void saveCollectionToFileCache(
     IonConfig config, Collection collection, Context context) throws IOException {
   String collectionUrl = IonPageUrls.getCollectionUrl(config);
   File filePath = FilePaths.getCollectionJsonPath(collectionUrl, config, context);
   String collectionJson = GsonHolder.getInstance().toJson(new CollectionResponse(collection));
   FileUtils.writeTextToFile(collectionJson, filePath);
 }
Пример #2
0
 private static FileWithMeta getFilePath(
     ArchiveIndex fileInfo, File collectionFolderTemp, IonConfig config, Context context) {
   File targetFile;
   IonRequestType type = null;
   String url = fileInfo.url;
   String pageIdentifier = null;
   String filename = FilePaths.getFileName(url);
   try {
     // check URL is a collections or pages call
     IonRequestInfo requestInfo = IonPageUrls.analyze(url, config);
     pageIdentifier = requestInfo.pageIdentifier;
     type = requestInfo.requestType;
     targetFile = FilePaths.getFilePath(url, config, context, true);
   } catch (NoIonPagesRequestException e) {
     IonLog.w(TAG, "URL " + url + " cannot be handled properly. Is it invalid?");
     targetFile = new File(collectionFolderTemp, filename);
   }
   return new FileWithMeta(targetFile, type, fileInfo, pageIdentifier);
 }