use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.
the class AppDB method getOrCreate.
public FileMeta getOrCreate(String path) {
FileMeta load = fileMetaDao.load(path);
try {
if (load == null) {
load = new FileMeta(path);
fileMetaDao.insert(load);
}
} catch (Exception e) {
LOG.e(e);
}
return load;
}
use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.
the class AppDB method clearAllStars.
public void clearAllStars() {
List<FileMeta> stars = fileMetaDao.queryBuilder().where(FileMetaDao.Properties.IsStar.eq(1)).list();
for (FileMeta meta : stars) {
meta.setIsStar(false);
}
fileMetaDao.updateInTx(stars);
}
use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.
the class AppDB method addStarFolder.
public void addStarFolder(String path) {
if (!new File(path).isDirectory()) {
LOG.d("Can't add to recent, it's not a file", path);
return;
}
LOG.d("addStarFile", path);
FileMeta load = getOrCreate(path);
load.setPathTxt(ExtUtils.getFileName(path));
load.setIsStar(true);
load.setIsStarTime(System.currentTimeMillis());
load.setCusType(FileMetaAdapter.DISPLAY_TYPE_DIRECTORY);
fileMetaDao.update(load);
}
use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.
the class ImageExtractor method proccessCoverPage.
public Bitmap proccessCoverPage(PageUrl pageUrl) {
String path = pageUrl.getPath();
if (pageUrl.getHeight() == 0) {
pageUrl.setHeight((int) (pageUrl.getWidth() * 1.5));
}
FileMeta fileMeta = AppDB.get().load(path);
EbookMeta ebookMeta = FileMetaCore.get().getEbookMeta(path, CacheDir.ZipApp, false);
LOG.d("proccessCoverPage fileMeta", fileMeta, pageUrl);
if (fileMeta == null) {
fileMeta = new FileMeta(path);
FileMetaCore.get().upadteBasicMeta(fileMeta, new File(path));
FileMetaCore.get().udpateFullMeta(fileMeta, ebookMeta);
AppDB.get().getDao().insert(fileMeta);
}
String unZipPath = ebookMeta.getUnzipPath();
Bitmap cover = null;
if (ebookMeta.coverImage != null) {
cover = BaseExtractor.arrayToBitmap(ebookMeta.coverImage, pageUrl.getWidth());
} else if (BookType.EPUB.is(unZipPath)) {
cover = BaseExtractor.arrayToBitmap(EpubExtractor.get().getBookCover(unZipPath), pageUrl.getWidth());
} else if (BookType.FB2.is(unZipPath)) {
cover = BaseExtractor.arrayToBitmap(Fb2Extractor.get().getBookCover(unZipPath), pageUrl.getWidth());
} else if (BookType.MOBI.is(unZipPath)) {
cover = BaseExtractor.arrayToBitmap(MobiExtract.getBookCover(unZipPath), pageUrl.getWidth());
} else if (BookType.RTF.is(unZipPath)) {
cover = BaseExtractor.arrayToBitmap(RtfExtract.getImageCover(unZipPath), pageUrl.getWidth());
} else if (BookType.PDF.is(unZipPath) || BookType.DJVU.is(unZipPath) || BookType.TIFF.is(unZipPath)) {
cover = proccessOtherPage(pageUrl, fileMeta);
} else if (BookType.CBZ.is(unZipPath) || BookType.CBR.is(unZipPath)) {
cover = BaseExtractor.arrayToBitmap(CbzCbrExtractor.getBookCover(unZipPath), pageUrl.getWidth());
} else if (ExtUtils.isFileArchive(unZipPath)) {
String ext = ExtUtils.getFileExtension(unZipPath);
cover = BaseExtractor.getBookCoverWithTitle("...", " [" + ext.toUpperCase(Locale.US) + "]", true);
pageUrl.tempWithWatermakr = true;
} else if (ExtUtils.isFontFile(unZipPath)) {
cover = BaseExtractor.getBookCoverWithTitle("font", "", true);
pageUrl.tempWithWatermakr = true;
}
if (cover == null) {
cover = BaseExtractor.getBookCoverWithTitle(fileMeta.getAuthor(), fileMeta.getTitle(), true);
pageUrl.tempWithWatermakr = true;
}
LOG.d("udpateFullMeta ImageExtractor", fileMeta.getAuthor());
AppDB.get().update(fileMeta);
return cover;
}
use of com.foobnix.dao2.FileMeta 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