示例#1
0
 /** Stop any movements. */
 public void stopMovement() {
   isBeingDragged = false;
   dragWasCanceled = true;
   if (!scroller.isFinished()) scroller.abortAnimation();
   if (getScrollX() != 0 || getScrollY() != 0) super.scrollTo(0, 0);
   update(false);
 }
示例#2
0
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   mScrollX = x;
   if (mEnabled) mViewBehind.scrollBehindTo(mContent, x, y);
   //		((SlidingMenu)getParent()).manageLayers(getPercentOpen());
 }
示例#3
0
 @Override
 public void scrollTo(int x, int y) {
   // TODO Auto-generated method stub
   super.scrollTo(x, y);
   if (null != sListener) {
     sListener.onOffsetChanged(getScrollX());
   }
   postInvalidate();
 }
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   mScrollX = x;
   mViewBehind.scrollBehindTo(mContent, x, y);
   ((SlidingMenu) getParent()).manageLayers(getPercentOpen());
   if (mTransformer != null) {
     invalidate();
   }
 }
示例#5
0
 /** package* */
 void toggleWordWrap() {
   ViewGroup vSrc = this.mWordWrap ? this.mWordWrapView : this.mNoWordWrapView;
   ViewGroup vDst = this.mWordWrap ? this.mNoWordWrapView : this.mWordWrapView;
   ViewGroup vSrcParent =
       this.mWordWrap ? this.mWordWrapView : (ViewGroup) this.mNoWordWrapView.getChildAt(0);
   ViewGroup vDstParent =
       this.mWordWrap ? (ViewGroup) this.mNoWordWrapView.getChildAt(0) : this.mWordWrapView;
   vSrc.setVisibility(View.GONE);
   vSrcParent.removeView(this.mEditor);
   vDstParent.addView(this.mEditor);
   vDst.setVisibility(View.VISIBLE);
   vDst.scrollTo(0, 0);
   this.mWordWrap = !this.mWordWrap;
 }
  @Override
  public void computeScroll() {

    if (mScroller.computeScrollOffset()) {
      mParentView.scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
      postInvalidate();

      if (mScroller.isFinished()) {

        if (onSildingFinishListener != null && isFinish) {
          onSildingFinishListener.onSildingFinish();
        }
      }
    }
  }
示例#7
0
 /**
  * Selects an item. Immediately scroll to this position.
  *
  * @param position
  */
 public void setSelection(int position) {
   if (adapter == null) throw new IllegalStateException();
   dataChanged = true;
   isBeingDragged = false;
   dragWasCanceled = true;
   if (!scroller.isFinished()) scroller.abortAnimation();
   if (getScrollX() != 0 || getScrollY() != 0) super.scrollTo(0, 0);
   previousSelectedObject = null;
   selectedPosition = position;
   if (LOG) LogManager.i(this, "setSelection: " + selectedPosition);
   update(false);
   if (selectedView == null) return;
   ListView listView = (ListView) selectedView.findViewById(android.R.id.list);
   listView.setAdapter(listView.getAdapter());
 }
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   mScrollX = x;
   mViewBehind.scrollBehindTo(mContent, x, y);
 }
示例#9
0
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   if (mTransformer != null) invalidate();
 }
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   mTouchX = x;
   mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
 }
示例#11
0
 @Override
 public void scrollTo(int x, int y) {
   if (LOG) LogManager.i(this, "scrollTo: " + x + "," + y);
   super.scrollTo(x, y);
   update(false);
 }
示例#12
0
  /**
   * Updates scrolling, creates views if necessary .
   *
   * @param layout whether we need to update layout (remeasure).
   */
  private void update(boolean layout) {
    // Process data change.
    final int count = getCount();
    if (dataChanged) {
      if (previousSelectedObject != null)
        for (int position = 0; position < count; position++)
          if (adapter.getItem(position).equals(previousSelectedObject)) {
            selectedPosition = position;
            if (LOG) LogManager.i(this, "Found selected position: " + selectedPosition);
            break;
          }
      selectedPosition = correntPosition(selectedPosition);
    }

    // Process scrolling.
    final int width = getWidth();
    int scrollX = getScrollX();
    if (width != 0) {
      while (scrollX >= width) {
        scrollX -= width;
        initialScrollX -= width;
        selectedPosition = correntPosition(selectedPosition + 1);
        if (LOG) LogManager.i(this, "scrollX >= width: " + selectedPosition);
      }
      while (scrollX <= -width) {
        scrollX += width;
        initialScrollX += width;
        selectedPosition = correntPosition(selectedPosition - 1);
        if (LOG) LogManager.i(this, "scrollX <= -width: " + selectedPosition);
      }
    }

    // Process low count.
    if (count < 2) {
      if (LOG) LogManager.i(this, "count < 2");
      dragWasCanceled = true;
      isBeingDragged = false;
      if (!scroller.isFinished()) scroller.abortAnimation();
      if (scrollX != 0) scrollX = 0;
    }

    // Store focus.
    final View focus;
    if (selectedView != null) focus = selectedView.findFocus();
    else focus = null;

    // Process selected view.
    if (count == 0) {
      if (LOG) LogManager.i(this, "count == 0");
      selectedPosition = -1;
      if (selectedView != null) {
        if (onSelectListener != null) onSelectListener.onUnselect();
        adapter.saveState(selectedView);
        removeViewInLayout(selectedView);
        selectedView = null;
        // We must invalidate to update view.
        invalidate();
      }
    } else {
      if (LOG) LogManager.i(this, "count > 0");

      // Exchange visible and selected views and previous objects.
      final Object selectedObject = adapter.getItem(selectedPosition);
      final boolean exchange =
          previousSelectedObject != null
              && previousVisibleObject != null
              && !previousSelectedObject.equals(selectedObject)
              && previousVisibleObject.equals(selectedObject);
      if (exchange) {
        Object tempObject = previousSelectedObject;
        previousSelectedObject = previousVisibleObject;
        previousVisibleObject = tempObject;
        View view = selectedView;
        selectedView = visibleView;
        visibleView = view;
      }

      // Update view.
      final boolean update =
          dataChanged
              || previousSelectedObject == null
              || !previousSelectedObject.equals(selectedObject);
      selectedView = getView(selectedPosition, 0, selectedView, update, layout);
      previousSelectedObject = selectedObject;
      if (update || exchange) if (onSelectListener != null) onSelectListener.onSelect();

      // Enable focusable.
      if (selectedView instanceof ViewGroup)
        ((ViewGroup) selectedView).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
      else selectedView.setFocusable(true);
    }

    // Process visible (not selected) view.
    if (count < 2) {
      if (LOG) LogManager.i(this, "count < 2 || scrollX == 0");
      visiblePosition = -1;
      if (visibleView != null) {
        adapter.saveState(visibleView);
        removeViewInLayout(visibleView);
        visibleView = null;
      }
    } else {
      // Calculate position.
      final int visibleX;
      if (scrollX > 0) {
        if (LOG) LogManager.i(this, "scrollX > 0");
        visiblePosition = correntPosition(selectedPosition + 1);
        visibleX = width;
      } else {
        if (LOG) LogManager.i(this, "scrollX < 0");
        visiblePosition = correntPosition(selectedPosition - 1);
        visibleX = -width;
      }

      // Update view.
      final Object visibleObject = adapter.getItem(visiblePosition);
      final boolean update =
          dataChanged
              || previousVisibleObject == null
              || !previousVisibleObject.equals(visibleObject);
      visibleView = getView(visiblePosition, visibleX, visibleView, update, layout);
      previousVisibleObject = visibleObject;

      // Disable focusable.
      if (visibleView instanceof ViewGroup)
        ((ViewGroup) visibleView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
      else visibleView.setFocusable(false);
    }

    // Restore focus by ID.
    if (selectedView != null) {
      View target;
      if (focus == null || focus.getId() == View.NO_ID) target = null;
      else target = selectedView.findViewById(focus.getId());
      if (target == null) target = selectedView.findViewById(R.id.chat_input);
      target.requestFocus();
    }

    if (scrollX == 0) {
      if (LOG) LogManager.i(this, "Scroll X == 0");
      hidePages();
    } else {
      if (LOG) LogManager.i(this, "Scroll X != 0");
      showPages();
    }

    super.scrollTo(scrollX, 0);

    dataChanged = false;
  }
示例#13
0
 @Override
 public void scrollTo(int x, int y) {
   super.scrollTo(x, y);
   postInvalidate();
 }