コード例 #1
0
ファイル: FoldController.java プロジェクト: hailongz/android
  @Override
  protected void didViewUnLoaded() {

    IViewController<T> topViewController = null;

    if (_topControllerDirection == TopControllerDirectionLeft) {

      topViewController = getLeftViewController();

      if (topViewController != null && topViewController.isViewAppeared()) {
        topViewController.viewRemoveForSuperView(false);
      }
    }

    if (_topControllerDirection == TopControllerDirectionRight) {

      topViewController = getRightViewController();

      if (topViewController != null && topViewController.isViewAppeared()) {
        topViewController.viewRemoveForSuperView(false);
      }
    }

    topViewController = getCenterViewController();

    if (topViewController != null && topViewController.isViewAppeared()) {
      topViewController.viewRemoveForSuperView(false);
    }

    _contentView = null;
    _gestureDetector = null;
    super.didViewUnLoaded();
  }
コード例 #2
0
ファイル: FoldController.java プロジェクト: hailongz/android
  @Override
  public String loadURL(URL url, String basePath, boolean animated) {

    basePath = URL.stringAddPathComponent(basePath, getAlias());

    String alias = url.firstPathComponent(basePath);

    if (alias != null) {

      IViewController<T> topController = getCenterViewController();

      if (topController == null || !alias.equals(topController.getAlias())) {

        if (topController != null) {
          if (topController.isViewAppeared()) {
            topController.viewRemoveForSuperView(animated);
          }
          topController.setParentController(null);
        }

        topController = getViewControllerContext().getViewController(url, basePath);

        if (topController != null) {

          topController.setParentController(this);

          View v = topController.getView();

          if (_topControllerDirection == TopControllerDirectionLeft) {
            v.setX(v.getWidth() - FoldWidth);
          } else if (_topControllerDirection == TopControllerDirectionRight) {
            v.setX(FoldWidth - v.getWidth());
          } else {
            v.setX(0);
          }

          if (isViewAppeared()) {
            topController.viewAppearToSuperView(getContentView(), animated);
          }

          setCenterViewController(topController);
        }
      }

      if (topController != null) {
        basePath = topController.loadURL(url, basePath, animated);
      }
    }

    return basePath;
  }
コード例 #3
0
ファイル: FoldController.java プロジェクト: hailongz/android
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

    float dx = e2.getX() - _gestureTouchX;

    if (distanceX < 0.0f) {
      _gestureDirection = GestureDirectionRight;
    } else {
      _gestureDirection = GestureDirectionLeft;
    }

    ViewGroup contentView = getContentView();

    if (dx == 0.0f) {

      IViewController<T> controller = getCenterViewController();

      if (controller != null) {
        View v = controller.getView();
        v.setX(dx);
      }

      controller = getLeftViewController();

      if (controller != null) {

        if (controller.isViewAppeared()) {
          controller.viewRemoveForSuperView(false);
        }
      }

      controller = getRightViewController();

      if (controller != null) {

        if (controller.isViewAppeared()) {
          controller.viewRemoveForSuperView(false);
        }
      }
    } else if (dx < 0.0f) {

      IViewController<T> controller = getLeftViewController();

      if (controller != null) {

        if (controller.isViewAppeared()) {
          controller.viewRemoveForSuperView(false);
        }
      }

      controller = getRightViewController();

      if (controller != null) {

        if (!controller.isViewAppeared()) {
          controller.viewAppearToSuperView(contentView, false, true);
        }

        View v = controller.getView();

        float alpha = AlphaValue - (1.0f - AlphaValue) * dx / contentView.getWidth();

        v.setAlpha(alpha);

        controller = getCenterViewController();

        if (controller != null) {
          v = controller.getView();
          v.setX(dx);
        }
      } else {

        controller = getCenterViewController();

        if (controller != null) {
          View v = controller.getView();
          v.setX(0);
        }
      }

    } else {

      IViewController<T> controller = getRightViewController();

      if (controller != null) {

        if (controller.isViewAppeared()) {
          controller.viewRemoveForSuperView(false);
        }
      }

      controller = getLeftViewController();

      if (controller != null) {

        if (!controller.isViewAppeared()) {
          controller.viewAppearToSuperView(contentView, false, true);
        }

        View v = controller.getView();

        float alpha = AlphaValue - (1.0f - AlphaValue) * dx / contentView.getWidth();

        v.setAlpha(alpha);

        controller = getCenterViewController();

        if (controller != null) {
          v = controller.getView();
          v.setX(dx);
        }
      } else {

        controller = getCenterViewController();

        if (controller != null) {
          View v = controller.getView();
          v.setX(0);
        }
      }
    }

    return true;
  }
コード例 #4
0
ファイル: FoldController.java プロジェクト: hailongz/android
  protected void setTopControllerDirection(int topControllerDirection, boolean animated) {

    if (getViewControllerContext().isIdleTimerDisabled() && animated && isViewAppeared()) {
      return;
    }

    if (_topControllerDirection != topControllerDirection) {

      getView();

      final ViewGroup contentView = getContentView();

      if (animated && isViewAppeared()) {

        switch (topControllerDirection) {
          case TopControllerDirectionCenter:
            {
              Animation anim = new Animation();

              anim.setDuration(300);
              anim.setListener(
                  new AnimatorListener() {

                    public void onEnd() {

                      IViewController<T> topController = getLeftViewController();

                      if (topController != null) {
                        if (topController.isViewAppeared()) {
                          topController.viewRemoveForSuperView(true);
                        }
                      }

                      topController = getRightViewController();

                      if (topController != null) {
                        if (topController.isViewAppeared()) {
                          topController.viewRemoveForSuperView(true);
                        }
                      }

                      contentView.setEnabled(true);
                      getViewControllerContext().setIdleTimerDisabled(false);
                    }

                    public void onAnimationStart(Animator animation) {}

                    public void onAnimationRepeat(Animator animation) {}

                    public void onAnimationEnd(Animator animation) {
                      onEnd();
                    }

                    public void onAnimationCancel(Animator animation) {
                      onEnd();
                    }
                  });

              IViewController<T> topController = getLeftViewController();

              if (topController != null) {
                if (topController.isViewAppeared()) {
                  anim.alpha(topController.getView(), 1.0f, AlphaValue);
                }
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                anim.translateTo(v, 0, 0);

                if (!topController.isViewAppeared()) {
                  topController.viewAppearToSuperView(contentView, animated);
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (topController.isViewAppeared()) {
                  anim.alpha(topController.getView(), 1.0f, AlphaValue);
                }
              }
              contentView.setEnabled(false);
              getViewControllerContext().setIdleTimerDisabled(true);
              anim.submit();
            }
            break;
          case TopControllerDirectionLeft:
            {
              Animation anim = new Animation();

              anim.setDuration(300);
              anim.setListener(
                  new AnimatorListener() {

                    public void onEnd() {

                      IViewController<T> topController = getRightViewController();

                      if (topController != null) {
                        if (topController.isViewAppeared()) {
                          topController.viewRemoveForSuperView(true);
                        }
                      }

                      contentView.setEnabled(true);
                      getViewControllerContext().setIdleTimerDisabled(false);
                    }

                    public void onAnimationStart(Animator animation) {}

                    public void onAnimationRepeat(Animator animation) {}

                    public void onAnimationEnd(Animator animation) {
                      onEnd();
                    }

                    public void onAnimationCancel(Animator animation) {
                      onEnd();
                    }
                  });

              IViewController<T> topController = getLeftViewController();

              if (topController != null) {

                if (!topController.isViewAppeared()) {
                  topController.viewAppearToSuperView(getContentView(), animated, true);
                }

                anim.alpha(topController.getView(), AlphaValue, 1.0f);
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                anim.translateTo(v, contentView.getWidth() - FoldWidth, 0);

                if (!topController.isViewAppeared()) {
                  topController.viewAppearToSuperView(getContentView(), animated);
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (topController.isViewAppeared()) {
                  anim.alpha(topController.getView(), 1.0f, AlphaValue);
                }
              }

              contentView.setEnabled(false);
              getViewControllerContext().setIdleTimerDisabled(true);
              anim.submit();
            }
            break;
          case TopControllerDirectionRight:
            {
              Animation anim = new Animation();

              anim.setDuration(300);
              anim.setListener(
                  new AnimatorListener() {

                    public void onEnd() {

                      IViewController<T> topController = getLeftViewController();

                      if (topController != null) {
                        if (topController.isViewAppeared()) {
                          topController.viewRemoveForSuperView(true);
                        }
                      }

                      contentView.setEnabled(true);
                      getViewControllerContext().setIdleTimerDisabled(false);
                    }

                    public void onAnimationStart(Animator animation) {}

                    public void onAnimationRepeat(Animator animation) {}

                    public void onAnimationEnd(Animator animation) {
                      onEnd();
                    }

                    public void onAnimationCancel(Animator animation) {
                      onEnd();
                    }
                  });

              IViewController<T> topController = getLeftViewController();

              if (topController != null) {
                if (topController.isViewAppeared()) {
                  anim.alpha(topController.getView(), 1.0f, AlphaValue);
                }
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                anim.translateTo(v, FoldWidth - contentView.getWidth(), 0);

                if (!topController.isViewAppeared()) {
                  topController.viewAppearToSuperView(contentView, animated);
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (!topController.isViewAppeared()) {
                  topController.viewAppearToSuperView(contentView, animated, true);
                }

                anim.alpha(topController.getView(), AlphaValue, 1.0f);
              }

              contentView.setEnabled(false);
              getViewControllerContext().setIdleTimerDisabled(true);
              anim.submit();
            }
            break;
        }

      } else {

        switch (topControllerDirection) {
          case TopControllerDirectionCenter:
            {
              IViewController<T> topController = getLeftViewController();

              if (topController != null) {
                if (topController.isViewAppeared()) {
                  topController.viewRemoveForSuperView(animated);
                }
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                v.setX(0);

                if (isViewAppeared()) {
                  if (!topController.isViewAppeared()) {
                    topController.viewAppearToSuperView(contentView, animated);
                  }
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (topController.isViewAppeared()) {
                  topController.viewRemoveForSuperView(animated);
                }
              }
            }
            break;
          case TopControllerDirectionLeft:
            {
              IViewController<T> topController = getLeftViewController();

              if (topController != null) {
                if (isViewAppeared()) {
                  if (!topController.isViewAppeared()) {
                    topController.viewAppearToSuperView(getContentView(), animated, true);
                  }
                }
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                v.setX(contentView.getWidth() - FoldWidth);

                if (isViewAppeared()) {
                  if (!topController.isViewAppeared()) {
                    topController.viewAppearToSuperView(getContentView(), animated);
                  }
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (topController.isViewAppeared()) {
                  topController.viewRemoveForSuperView(animated);
                }
              }
            }
            break;
          case TopControllerDirectionRight:
            {
              IViewController<T> topController = getLeftViewController();

              if (topController != null) {
                if (topController.isViewAppeared()) {
                  topController.viewRemoveForSuperView(animated);
                }
              }

              topController = getCenterViewController();

              if (topController != null) {

                View v = topController.getView();

                v.setX(FoldWidth - contentView.getWidth());

                if (isViewAppeared()) {
                  if (!topController.isViewAppeared()) {
                    topController.viewAppearToSuperView(contentView, animated);
                  }
                }
              }

              topController = getRightViewController();

              if (topController != null) {

                if (isViewAppeared()) {
                  if (!topController.isViewAppeared()) {
                    topController.viewAppearToSuperView(contentView, animated, true);
                  }
                }
              }
            }
            break;
        }
      }

      _topControllerDirection = topControllerDirection;
    }
  }