Search in sources :

Example 11 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class AppDB method getAllRecentWithProgress.

public List<FileMeta> getAllRecentWithProgress() {
    List<FileMeta> list = fileMetaDao.queryBuilder().where(FileMetaDao.Properties.IsRecent.eq(1)).orderDesc(FileMetaDao.Properties.IsRecentTime).list();
    for (FileMeta meta : list) {
        BookSettings bs = SettingsManager.getTempBookSettings(meta.getPath());
        try {
            float isRecentProgress = (float) (bs.currentPage.viewIndex + 1) / bs.getPages();
            if (isRecentProgress > 1) {
                isRecentProgress = 1;
            }
            if (isRecentProgress < 0) {
                isRecentProgress = 0;
            }
            meta.setIsRecentProgress(isRecentProgress);
        } catch (Exception e) {
            LOG.d(e);
            meta.setIsRecentProgress(1f);
        }
    }
    return removeNotExist(list);
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings) FileMeta(com.foobnix.dao2.FileMeta)

Example 12 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class HorizontalModeController method saveCurrentPage.

public void saveCurrentPage() {
    if (TempHolder.get().loadingCancelled) {
        LOG.d("Loading cancelled");
        return;
    }
    // int page = PageUrl.fakeToReal(currentPage);
    LOG.d("_PAGE", "saveCurrentPage", currentPage, pagesCount);
    try {
        BookSettings bs = SettingsManager.getBookSettings(getBookPath());
        bs.updateFromAppState();
        bs.currentPageChanged(new PageIndex(currentPage, currentPage), pagesCount);
        bs.save();
    } catch (Exception e) {
        LOG.e(e);
    }
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings) PageIndex(org.ebookdroid.core.PageIndex)

Example 13 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class ViewerActivityController method currentPageChanged.

@Override
public void currentPageChanged(final PageIndex newIndex, int pages) {
    final int pageCount = documentModel.getPageCount();
    String pageText = "";
    if (pageCount > 0) {
        pageText = (newIndex.viewIndex + 1) + "/" + pageCount;
    }
    try {
        BookSettings bs = SettingsManager.getBookSettings(controller.getCurrentBook().getPath());
        bs.updateFromAppState();
        bs.currentPageChanged(newIndex, pageCount);
        bs.save();
    } catch (Exception e) {
        LOG.e(e);
    }
    wrapperControlls.updateUI();
    wrapperControlls.setTitle(bookTitle);
    controller.setTitle(bookTitle);
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings) MuPdfPasswordException(org.ebookdroid.droids.mupdf.codec.exceptions.MuPdfPasswordException)

Example 14 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class ViewerActivityController method onPause.

public void onPause() {
    if (wrapperControlls != null) {
        wrapperControlls.onPause();
    }
    BookSettings bookSettings = SettingsManager.getBookSettings();
    if (bookSettings != null) {
        bookSettings.updateFromAppState();
        bookSettings.save();
    }
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Example 15 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class DocumentModel method initPages.

public void initPages(final IActivityController base, final IProgressIndicator task) {
    recyclePages();
    final BookSettings bs = SettingsManager.getBookSettings();
    if (base == null || bs == null || context == null || decodeService == null) {
        return;
    }
    final IView view = base.getView();
    final CodecPageInfo defCpi = new CodecPageInfo();
    defCpi.width = (view.getWidth());
    defCpi.height = (view.getHeight());
    int viewIndex = 0;
    try {
        final ArrayList<Page> list = new ArrayList<Page>();
        final CodecPageInfo[] infos = retrievePagesInfo(base, bs, task);
        for (int docIndex = 0; docIndex < infos.length; docIndex++) {
            if (TempHolder.get().loadingCancelled) {
                return;
            }
            if (!AppState.get().isCut) {
                CodecPageInfo cpi = infos[docIndex] != null ? infos[docIndex] : defCpi;
                final Page page = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.FULL_PAGE, cpi);
                list.add(page);
            } else {
                final Page page1 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.LEFT_PAGE, infos[docIndex]);
                final Page page2 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.RIGHT_PAGE, infos[docIndex]);
                if (AppState.get().isCutRTL) {
                    list.add(page2);
                    list.add(page1);
                } else {
                    list.add(page1);
                    list.add(page2);
                }
            }
        }
        pages = list.toArray(new Page[list.size()]);
    } finally {
    }
}
Also used : IView(org.ebookdroid.ui.viewer.IView) CodecPageInfo(org.ebookdroid.core.codec.CodecPageInfo) ArrayList(java.util.ArrayList) BookSettings(org.ebookdroid.common.settings.books.BookSettings) Page(org.ebookdroid.core.Page) PageIndex(org.ebookdroid.core.PageIndex)

Aggregations

BookSettings (org.ebookdroid.common.settings.books.BookSettings)15 RectF (android.graphics.RectF)3 PageIndex (org.ebookdroid.core.PageIndex)3 Matrix (android.graphics.Matrix)2 FileMeta (com.foobnix.dao2.FileMeta)2 PageAlign (org.ebookdroid.common.settings.types.PageAlign)2 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 EditText (android.widget.EditText)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1