Пример #1
0
  /**
   * Switch to page at given index
   *
   * @param index
   */
  public void switchToPage(int index) {

    closeCurrentPages();
    IPage page;
    if (pageController2 != null) {
      if ((!showCover && index % 2 > 0) || (showCover && index % 2 == 0 && index > 0)) {
        index -= 1;
      }
    }
    if (index < contentModel.getPages().getTotalPageCount()) {
      page = contentModel.getPage(index);
    } else {
      page = contentModel.getPage(0);
    }

    if (showCover && index == 0) {
      playerView.showSinglePage();
      switchToPage(page, pageController1);
    } else {
      switchToPage(page, pageController1);
      if (pageController2 != null && index + 1 < contentModel.getPages().getTotalPageCount()) {
        playerView.showTwoPages();
        page = contentModel.getPage(index + 1);
        switchToPage(page, pageController2);
      }
    }
  }
Пример #2
0
  private void createPageControllers(boolean bookMode) {

    pageController1 = new PageController(this);
    pageController1.setView(playerView.getPageView(0));
    if (bookMode) {
      playerView.showTwoPages();
      pageController2 = new PageController(this);
      pageController2.setView(playerView.getPageView(1));
    }
  }
Пример #3
0
 public void initHeaders() {
   if (contentModel.getHeader() != null) {
     playerView.showHeader();
     headerController = new PageController(pageController1.getPlayerServices());
     headerController.setView(playerView.getHeaderView());
     //			headerController.setPage(contentModel.getHeader());
   }
   if (contentModel.getFooter() != null) {
     playerView.showFooter();
     footerController = new PageController(pageController1.getPlayerServices());
     footerController.setView(playerView.getFooterView());
     //			footerController.setPage(contentModel.getFooter());
   }
 }
Пример #4
0
  private void switchToPage(IPage page, final PageController pageController) {

    HashMap<String, String> params = new HashMap<String, String>();
    params.put("page", page.getId());
    sendAnalytics("switch to page", params);
    // Load new page
    String baseUrl = contentModel.getBaseUrl();
    XMLLoader reader = new XMLLoader((IXMLSerializable) page);
    String url = URLUtils.resolveURL(baseUrl, page.getHref());
    playerView.showWaitDialog();
    reader.load(
        url,
        new ILoadListener() {

          @Override
          public void onFinishedLoading(Object obj) {
            Page page = (Page) obj;
            pageLoaded(page, pageController);
            if (pageLoadListener != null) {
              pageLoadListener.onFinishedLoading(obj);
            }
            playerView.hideWaitDialog();
            if (timeStart == 0) {
              timeStart = System.currentTimeMillis();
            }
            scrollViewToBeggining();
          }

          @Override
          public void onError(String error) {
            playerView.hideWaitDialog();
            JavaScriptUtils.log("Can't load page: " + error);
          }
        });
  }
Пример #5
0
  public PlayerController(Content content, PlayerView view, boolean bookMode) {

    contentModel = content;
    playerView = view;
    playerView.setPlayerController(this);
    sessionId = UUID.uuid();
    scoreService = new ScoreService(contentModel.getScoreType() == ScoreType.last);
    stateService = new StateService();
    createPageControllers(bookMode);
  }