当前位置: 首页>>代码示例>>Java>>正文


Java EdgeEffectCompat.onPull方法代码示例

本文整理汇总了Java中android.support.v4.widget.EdgeEffectCompat.onPull方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeEffectCompat.onPull方法的具体用法?Java EdgeEffectCompat.onPull怎么用?Java EdgeEffectCompat.onPull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.EdgeEffectCompat的用法示例。


在下文中一共展示了EdgeEffectCompat.onPull方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);
    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang);
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }
    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);
        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                ViewCompat.postInvalidateOnAnimation(this);
            }
        }
    }
    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:SNiels,项目名称:Multi-Mania-app,代码行数:44,代码来源:StaggeredGridView.java

示例2: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaX Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaX, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaX);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaX > 0) {
            overhang = fillLeft(mFirstPosition - 1, allowOverhang);
            up = true;
        } else {
            overhang = fillRight(mFirstPosition + getChildCount(), allowOverhang);
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {

            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaX > 0 ? mLeftEdge : mRightEdge;
                edge.onPull((float) Math.abs(deltaX) / getWidth());
                ViewCompat.postInvalidateOnAnimation(this);
            }
        }
    }

    return deltaX == 0 || movedBy != 0;
}
 
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:49,代码来源:GalleryThumbnailView.java

示例3: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang)+ mItemMargin;
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                invalidate();
            }
        }
    }

    if (mSelectorPosition != INVALID_POSITION) {
        final int childIndex = mSelectorPosition - mFirstPosition;
        if (childIndex >= 0 && childIndex < getChildCount()) {
            positionSelector(INVALID_POSITION, getChildAt(childIndex));
        }
    } else {
        mSelectorRect.setEmpty();
    }

    if (mOnScrollListener != null) {
        mOnScrollListener.onScroll(null, getFirstPosition(), getChildCount(), this.mItemCount);
    }

    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:GMAndroidTeam,项目名称:Android-PullToRefresh,代码行数:61,代码来源:StaggeredGridView.java

示例4: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang)+ mItemMargin;
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                invalidate();
            }
        }
    }

    if (mSelectorPosition != INVALID_POSITION) {
        final int childIndex = mSelectorPosition - mFirstPosition;
        if (childIndex >= 0 && childIndex < getChildCount()) {
            positionSelector(INVALID_POSITION, getChildAt(childIndex));
        }
    } else {
        mSelectorRect.setEmpty();
    }

    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:TwentySevenC,项目名称:Flickr-Photos,代码行数:57,代码来源:StaggeredGridView.java

示例5: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll)
{
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits)
    {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0)
        {
            overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin;
            up = true;
        }
        else
        {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    }
    else
    {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll)
    {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits))
        {
            if (overScrolledBy > 0)
            {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                invalidate();
            }
        }
    }

    if (mSelectorPosition != INVALID_POSITION)
    {
        final int childIndex = mSelectorPosition - mFirstPosition;
        if (childIndex >= 0 && childIndex < getChildCount())
        {
            positionSelector(INVALID_POSITION, getChildAt(childIndex));
        }
    }
    else
    {
        mSelectorRect.setEmpty();
    }

    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:kimkha,项目名称:Finanvita,代码行数:70,代码来源:StaggeredGridView.java

示例6: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang)+ mItemMargin;
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);
 
        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                invalidate();
            }
        }
    }

    if (mSelectorPosition != INVALID_POSITION) {
        final int childIndex = mSelectorPosition - mFirstPosition;
        if (childIndex >= 0 && childIndex < getChildCount()) {
            positionSelector(INVALID_POSITION, getChildAt(childIndex));
        }
    } else {
        mSelectorRect.setEmpty();
    }
    
    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:oguzbilgener,项目名称:tuo-android,代码行数:57,代码来源:StaggeredGridView.java

示例7: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);

    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        final int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang) + mItemMargin;
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
            up = false;
        }
        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
            if (overScrolledBy > 0) {
                EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                invalidate();
            }
        }
    }

    if (mSelectorPosition != INVALID_POSITION) {
        final int childIndex = mSelectorPosition - mFirstPosition;
        if (childIndex >= 0 && childIndex < getChildCount()) {
            positionSelector(INVALID_POSITION, getChildAt(childIndex));
        }
    } else {
        mSelectorRect.setEmpty();
    }

    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:zhangdi0917,项目名称:SexyBelle,代码行数:56,代码来源:StaggeredGridView.java

示例8: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
 *
 * @param deltaY Pixels that content should move by
 * @return true if the movement completed, false if it was stopped prematurely.
 */
private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
    final boolean contentFits = contentFits();
    final int allowOverhang = Math.abs(deltaY);
    final int overScrolledBy;
    final int movedBy;
    if (!contentFits) {
        int overhang;
        final boolean up;
        mPopulating = true;
        if (deltaY > 0) {
            overhang = fillUp(mFirstPosition - 1, allowOverhang);
            up = true;
        } else {
            overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang);

            if (overhang < 0) {
                // Overhang when filling down indicates how many pixels past the bottom of the
                // screen has been filled in.  If this value is negative, it should be set to
                // 0 so that we don't allow over scrolling.
                overhang = 0;
            }

            up = false;
        }

        movedBy = Math.min(overhang, allowOverhang);
        offsetChildren(up ? movedBy : -movedBy);
        recycleOffscreenViews();
        mPopulating = false;
        overScrolledBy = allowOverhang - overhang;
    } else {
        overScrolledBy = allowOverhang;
        movedBy = 0;
    }

    if (allowOverScroll) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);

        if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {

            if (overScrolledBy > 0) {
                final EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                edge.onPull((float) Math.abs(deltaY) / getHeight());
                ViewCompat.postInvalidateOnAnimation(this);
            }
        }
    }

    awakenScrollBars(0 /* show immediately */, true /* invalidate */);
    return deltaY == 0 || movedBy != 0;
}
 
开发者ID:ocae,项目名称:countdown,代码行数:58,代码来源:StaggeredGridView.java

示例9: trackMotionScroll

import android.support.v4.widget.EdgeEffectCompat; //导入方法依赖的package包/类
/**
   *
   * @param deltaY Pixels that content should move by
   * @return true if the movement completed, false if it was stopped prematurely.
   */
  private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
      final boolean contentFits = contentFits();
      final int allowOverhang = Math.abs(deltaY);

      final int overScrolledBy;
      final int movedBy;
      if (!contentFits) {
          final int overhang;
          final boolean up;
          mPopulating = true;
          if (deltaY > 0) {
              overhang = fillUp(mFirstPosition - 1, allowOverhang)+ mItemMargin;
              up = true;
          } else {
              overhang = fillDown(mFirstPosition + getChildCount(), allowOverhang) + mItemMargin;
              up = false;
          }
          movedBy = Math.min(overhang, allowOverhang);
          offsetChildren(up ? movedBy : -movedBy);
          recycleOffscreenViews();
          mPopulating = false;
          overScrolledBy = allowOverhang - overhang;
      } else {
          overScrolledBy = allowOverhang;
          movedBy = 0;
      }

      if (allowOverScroll) {
          final int overScrollMode = ViewCompat.getOverScrollMode(this);

          if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS ||
                  (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits)) {
              if (overScrolledBy > 0) {
                  EdgeEffectCompat edge = deltaY > 0 ? mTopEdge : mBottomEdge;
                  edge.onPull((float) Math.abs(deltaY) / getHeight());
                  invalidate();
              }
          }
      }

      if (mSelectorPosition != INVALID_POSITION) {
          final int childIndex = mSelectorPosition - mFirstPosition;
          if (childIndex >= 0 && childIndex < getChildCount()) {
              positionSelector(INVALID_POSITION, getChildAt(childIndex));
          }
      } else {
          mSelectorRect.setEmpty();
      }

if (mOnScrollListener != null) {
          mOnScrollListener.onScroll(null, getFirstPosition(), getChildCount(), this.mItemCount);
      }

      return deltaY == 0 || movedBy != 0;
  }
 
开发者ID:kitek,项目名称:PullToRefresh-StaggeredGridView,代码行数:61,代码来源:StaggeredGridView.java


注:本文中的android.support.v4.widget.EdgeEffectCompat.onPull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。