コード例 #1
0
ファイル: PageActivity.java プロジェクト: shangrz/FlipDroid
  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");
  }
コード例 #2
0
ファイル: PageActivity.java プロジェクト: shangrz/FlipDroid
  private Animation buildFlipHorizonalAnimation(final boolean forward) {
    final float centerY = container.getHeight() / 2.0f;
    final float centerX = 0;
    long duration = getFlipDurationFromPreference();

    Animation rotation =
        AnimationFactory.buildHorizontalFlipAnimation(forward, duration, centerX, centerY);

    rotation.setAnimationListener(flipAnimationListener);
    return rotation;
  }
コード例 #3
0
ファイル: PageActivity.java プロジェクト: shangrz/FlipDroid
  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);
      }
    }
  }