Search in sources :

Example 16 with FileMeta

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;
}
Also used : FileMeta(com.foobnix.dao2.FileMeta)

Example 17 with FileMeta

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);
}
Also used : FileMeta(com.foobnix.dao2.FileMeta)

Example 18 with FileMeta

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);
}
Also used : File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 19 with FileMeta

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;
}
Also used : RawBitmap(org.ebookdroid.common.bitmaps.RawBitmap) Bitmap(android.graphics.Bitmap) EbookMeta(com.foobnix.ext.EbookMeta) File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 20 with FileMeta

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;
}
Also used : PageCacheFile(org.ebookdroid.common.cache.PageCacheFile) CodecPageInfo(org.ebookdroid.core.codec.CodecPageInfo) FileMeta(com.foobnix.dao2.FileMeta)

Aggregations

FileMeta (com.foobnix.dao2.FileMeta)42 File (java.io.File)26 View (android.view.View)10 OnClickListener (android.view.View.OnClickListener)10 ImageView (android.widget.ImageView)10 TextView (android.widget.TextView)10 Intent (android.content.Intent)8 Bitmap (android.graphics.Bitmap)8 ArrayList (java.util.ArrayList)6 TargetApi (android.annotation.TargetApi)4 AlertDialog (android.app.AlertDialog)4 DialogInterface (android.content.DialogInterface)4 DocumentFile (android.support.v4.provider.DocumentFile)4 RecyclerView (android.support.v7.widget.RecyclerView)4 HorizontalViewActivity (com.foobnix.pdf.search.activity.HorizontalViewActivity)4 MainTabs2 (com.foobnix.ui2.MainTabs2)4 SuppressLint (android.annotation.SuppressLint)3 PendingIntent (android.app.PendingIntent)3 OnDismissListener (android.content.DialogInterface.OnDismissListener)3 Uri (android.net.Uri)3