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);
}
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);
}
}
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);
}
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();
}
}
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 {
}
}
Aggregations