Ejemplo n.º 1
0
  public void initPages(
      final IActivityController base, final IActivityController.IBookLoadTask 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;

    final long start = System.currentTimeMillis();
    try {
      final ArrayList<Page> list = new ArrayList<Page>();
      final CodecPageInfo[] infos = retrievePagesInfo(base, bs, task);

      for (int docIndex = 0; docIndex < infos.length; docIndex++) {
        if (!bs.splitPages
            || infos[docIndex] == null
            || (infos[docIndex].width < infos[docIndex].height)) {
          final Page page =
              new Page(
                  base,
                  new PageIndex(docIndex, viewIndex++),
                  PageType.FULL_PAGE,
                  infos[docIndex] != null ? infos[docIndex] : defCpi);
          list.add(page);
        } else {
          final Page page1 =
              new Page(
                  base, new PageIndex(docIndex, viewIndex++), PageType.LEFT_PAGE, infos[docIndex]);
          list.add(page1);
          final Page page2 =
              new Page(
                  base, new PageIndex(docIndex, viewIndex++), PageType.RIGHT_PAGE, infos[docIndex]);
          list.add(page2);
        }
      }
      pages = list.toArray(new Page[list.size()]);
      if (pages.length > 0) {
        createBookThumbnail(bs, pages[0], false);
      }
    } finally {
      LCTX.d("Loading page info: " + (System.currentTimeMillis() - start) + " ms");
    }
  }
Ejemplo n.º 2
0
 public void recycle() {
   decodeService.recycle();
   recyclePages();
 }