Ejemplo n.º 1
0
  private void flipPage(final boolean forward) {
    if (!current.isFirstPage()) flipStarted = true;

    this.previousDirection = this.forward;
    this.forward = forward;

    if (!forward) decreasePageNo();

    int nextPageIndex = forward ? currentPageIndex + 1 : currentPageIndex;
    System.out.println("debug flip");
    if (currentPageIndex == -1 && forward) { // we are first timer
      currentPageIndex++;
      container.addView(current, pageViewLayoutParamsFront);
      slideToNextPageAsynchronized();
    } else if (nextPageIndex > 0) {

      if (current.isLastPage() && forward) {
        finishActivity();
      }
      slideToNextPageAsynchronized();
    } else {
      if (pageIndexView.isHasUpdate()) {
        this.reload();
        return;
      } else {
        finishActivity();
      }
    }
    System.out.println("debug flip done");
  }
Ejemplo n.º 2
0
  private void slideToNextPage() {
    System.out.println("debug slide to next");
    try {
      if (preparingWindow == null && !prepareFail)
        preparingWindow =
            forward ? slidingWindows.getNextWindow() : slidingWindows.getPreviousWindow();
      else {
        if (previousDirection != forward) {
          if (previousDirection) {
            if (currentPageIndex == 0) {
              finishActivity();
              return;
            }
            preparingWindow = slidingWindows.getPreviousWindow();
            preparingWindow = slidingWindows.getPreviousWindow();
          } else {
            preparingWindow = slidingWindows.getNextWindow();
            preparingWindow = slidingWindows.getNextWindow();
          }
        }
        if (next.isLastPage()) {
          handler.post(
              new Runnable() {
                public void run() {
                  showAnimation();
                }
              });
          return;
        }
        boolean preparingWindowReady = preparingWindow.isLoaded();
        if (!preparingWindowReady) {
          preparingWindow.registerOnLoadListener(PageActivity.this);
          handler.post(
              new Runnable() {
                public void run() {
                  current.showLoading();
                }
              });
          return;
        }
      }
      final com.goal98.flipdroid.model.Window nextWindow = preparingWindow;
      preparingWindow = null;
      if (nextWindow.isLoading()) {
        // Log.d("SLIDING", "register on load listener...");

        handler.post(
            new Runnable() {
              public void run() {
                nextWindow.registerOnLoadListener(PageActivity.this);
                current.showLoading();
              }
            });
        return;
      } else if (nextWindow.isSkip()) {
        // Log.d("SLIDING", "slide to next page...");
        current.setLoadingNext(false);
        slideToNextPage();
        return;
      } else {
        if (next.isLastPage()) {
          //// System.out.println("lastpage");
        } else {
          if (forward) next = nextWindow.get();
          else previous = nextWindow.get();
        }

        handler.post(
            new Runnable() {
              public void run() {
                if (forward) next.removeLoadingIfNecessary();
                else {
                  if (previous == null) return;
                  previous.removeLoadingIfNecessary();
                }
                showAnimation();
              }
            });
      }
    } catch (Exception e) {
      e.printStackTrace();
      next = pageViewFactory.createLastPage();
      handler.post(
          new Runnable() {
            public void run() {
              showAnimation();
            }
          });
    }
  }
Ejemplo n.º 3
0
  private void showAnimation() {

    enlargedMode = false;
    renderNextPageIfNotRendered();
    // Log.d("ANI", "start animation");
    container.removeAllViews();
    if (current.isFirstPage()) {
      next.setVisibility(View.VISIBLE);
      currentPageIndex++;
      container.addView(current, pageViewLayoutParamsBack);
      container.addView(next, pageViewLayoutParamsFront);
      current.startAnimation(fadeInPageView);
    } else if (isWeiboMode()
        || next.isLastPage()
        || next.getWrapperViews().size() < 2
        || lastFlipDirection == ACTION_HORIZONTAL) {

      Animation rotation = buildFlipHorizonalAnimation(forward);
      if (forward) next.setVisibility(View.VISIBLE);
      else previous.setVisibility(View.VISIBLE);
      if (forward) {
        currentPageIndex++;

        container.addView(current, pageViewLayoutParamsBack);
        container.addView(next, pageViewLayoutParamsFront);
        current.startAnimation(rotation);
      } else {

        container.addView(current, pageViewLayoutParamsFront);
        container.addView(previous, pageViewLayoutParamsBack);
        previous.startAnimation(rotation);
      }
    } else {
      if (forward) {
        currentPageIndex++;
        container.addView(next, pageViewLayoutParamsFront);
      } else {
        container.addView(previous, pageViewLayoutParamsFront);
      }
      container.addView(current, pageViewLayoutParamsBack);

      if (forward) {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = next.getWrapperViews().get(0);
        nextBottom = next.getWrapperViews().get(1);
        final Animation flipToNext =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, true);
        currentBottom.startAnimation(flipToNext);
      } else {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = previous.getWrapperViews().get(0);
        nextBottom = previous.getWrapperViews().get(1);

        final Animation flipToPrevious =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, false);
        currentUpper.startAnimation(flipToPrevious);
      }
    }
  }