use of org.ebookdroid.common.cache.PageCacheFile in project LibreraReader by foobnix.
the class DocumentModel method retrievePagesInfo.
private CodecPageInfo[] retrievePagesInfo(final IActivityController base, final BookSettings bs, final IProgressIndicator task) {
int pagesCount = base.getDecodeService().getPageCount();
final PageCacheFile pagesFile = CacheManager.getPageFile(bs.fileName, pagesCount);
try {
if (pagesCount > 0) {
FileMeta meta = AppDB.get().load(bs.fileName);
if (meta != null) {
meta.setPages(pagesCount);
AppDB.get().update(meta);
}
}
} catch (Exception e) {
LOG.e(e);
}
if (decodeService.isPageSizeCacheable() && pagesFile.exists()) {
final CodecPageInfo[] infos = pagesFile.load();
if (infos != null && infos.length == decodeService.getPageCount()) {
return infos;
}
}
final CodecPageInfo[] infos = new CodecPageInfo[decodeService.getPageCount()];
final CodecPageInfo unified = decodeService.getUnifiedPageInfo();
for (int i = 0; i < infos.length; i++) {
if (TempHolder.get().loadingCancelled) {
return null;
}
infos[i] = unified != null ? unified : decodeService.getPageInfo(i);
}
if (decodeService.isPageSizeCacheable()) {
pagesFile.save(infos);
}
return infos;
}
Aggregations