當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。