android.widget.AbsListView#getPaddingTop ( )源码实例Demo

下面列出了android.widget.AbsListView#getPaddingTop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Utility method to check whether a {@link View} can scroll up from it's current position.
 * Handles platform version differences, providing backwards compatible functionality where
 * needed.
 */
private static boolean canViewScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        // For ICS and above we can call canScrollVertically() to determine this
        return ViewCompat.canScrollVertically(view, -1);
    } else {
        if (view instanceof AbsListView) {
            // Pre-ICS we need to manually check the first visible item and the child view's top
            // value
            final AbsListView listView = (AbsListView) view;
            return listView.getChildCount() > 0 &&
                    (listView.getFirstVisiblePosition() > 0
                            || listView.getChildAt(0).getTop() < listView.getPaddingTop());
        } else {
            // For all other view types we just check the getScrollY() value
            return view.getScrollY() > 0;
        }
    }
}
 
源代码2 项目: BaseProject   文件: VRefreshLayout.java
private boolean isTheViewCanScrollDown(View canScrolableView) {
    if (canScrolableView != null) {
        if (android.os.Build.VERSION.SDK_INT < 14) {//android 4.0以下
            if (canScrolableView instanceof AbsListView) {
                final AbsListView absListView = (AbsListView) canScrolableView;
                return absListView.getChildCount() > 0
                        && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                        .getTop() < absListView.getPaddingTop());
            }
            else {
                return ViewCompat.canScrollVertically(canScrolableView, -1) || canScrolableView.getScrollY() > 0;
            }
        } else {
            return ViewCompat.canScrollVertically(canScrolableView, -1);
        }
    }
    return false;
}
 
源代码3 项目: FamilyChat   文件: CommonPtrLayout.java
private boolean canScrollUp(View view)
{
    if (android.os.Build.VERSION.SDK_INT < 14)
    {
        if (view instanceof AbsListView)
        {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else
        {
            return ViewCompat.canScrollVertically(view, -1) || view.getScrollY() > 0;
        }
    } else
    {
        return ViewCompat.canScrollVertically(view, -1);
    }
}
 
源代码4 项目: Qiitanium   文件: MultiSwipeRefreshLayout.java
/**
 * Utility method to check whether a {@link View} can scroll up from it's current position.
 * Handles platform version differences, providing backwards compatible functionality where
 * needed.
 */
private static boolean canViewScrollUp(View view) {
  if (android.os.Build.VERSION.SDK_INT >= 14) {
    // For ICS and above we can call canScrollVertically() to determine this
    return ViewCompat.canScrollVertically(view, -1);
  } else {
    if (view instanceof AbsListView) {
      // Pre-ICS we need to manually check the first setVisible item and the child view's top
      // value
      final AbsListView listView = (AbsListView) view;
      return listView.getChildCount() > 0 &&
          (listView.getFirstVisiblePosition() > 0
              || listView.getChildAt(0).getTop() < listView.getPaddingTop());
    } else {
      // For all other view types we just check the getScrollY() value
      return view.getScrollY() > 0;
    }
  }
}
 
源代码5 项目: AgentWebX5   文件: ScrollingUtil.java
/**
 * 用来判断是否可以下拉
 * 手指在屏幕上该方法才有效
 */
public static boolean canChildScrollUp(View mChildView) {
    if (mChildView == null) {
        return false;
    }
    if (Build.VERSION.SDK_INT < 14) {
        if (mChildView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mChildView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mChildView, -1) || mChildView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mChildView, -1);
    }
}
 
public boolean canChildScrollUp() {
    if (mScrollableChildView != null) {
        if (android.os.Build.VERSION.SDK_INT < 14) {
            if (mScrollableChildView instanceof AbsListView) {
                final AbsListView absListView = (AbsListView) mScrollableChildView;
                return absListView.getChildCount() > 0
                        && (absListView.getFirstVisiblePosition() > 0
                        || absListView.getChildAt(0)
                        .getTop() < absListView.getPaddingTop());
            } else if (
                    RECYCLERVIEW_CLASS_NAME.equals(mScrollableChildView.getClass().getName())) {
                final RecyclerView recyclerView = (RecyclerView) mScrollableChildView;
                View firstView = recyclerView.getChildAt(0);
                return recyclerView.getChildCount() > 0
                        && (recyclerView.getLayoutManager().getPosition(firstView) > 0
                        || recyclerView.getChildAt(0).getTop() < recyclerView.getPaddingTop());
            } else {
                return mScrollableChildView.getScrollY() > 0;
            }
        } else {
            return ViewCompat.canScrollVertically(mScrollableChildView, -1);
        }
    }
    return false;
}
 
源代码7 项目: AutoRecycleView   文件: SuperSwipeRefreshLayout.java
/**
 * 判断目标View是否滑动到顶部-还能否继续滑动
 *
 * @return
 */
public boolean isChildScrollToTop() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return !(absListView.getChildCount() > 0 && (absListView
                    .getFirstVisiblePosition() > 0 || absListView
                    .getChildAt(0).getTop() < absListView.getPaddingTop()));
        } else {
            return !(mTarget.getScrollY() > 0);
        }
    } else {
        return !ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
源代码8 项目: UltimateAndroid   文件: PullRefreshLayout.java
private boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
@Override
public boolean canChildScrollUp() {
    if (view != null && view instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) view;
        return absListView.getChildCount() > 0
                && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                .getTop() < absListView.getPaddingTop());
    }
    return super.canChildScrollUp();
}
 
源代码10 项目: Study_Android_Demo   文件: PtrDefaultHandler.java
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
源代码11 项目: UltimateAndroid   文件: PullRefreshLayout.java
private boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
源代码12 项目: AndroidStudyDemo   文件: BGAScrollingUtil.java
public static boolean isAbsListViewToTop(AbsListView absListView) {
    if (absListView != null) {
        int firstChildTop = 0;
        if (absListView.getChildCount() > 0) {
            // 如果AdapterView的子控件数量不为0,获取第一个子控件的top
            firstChildTop = absListView.getChildAt(0).getTop() - absListView.getPaddingTop();
        }
        if (absListView.getFirstVisiblePosition() == 0 && firstChildTop == 0) {
            return true;
        }
    }
    return false;
}
 
源代码13 项目: MaterialQQLite   文件: PullRefreshLayout.java
private boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
/**
 * copy from {@link android.support.v4.widget.SwipeRefreshLayout#canChildScrollUp()}
 *
 * @return Whether it is possible for the child view of this layout to
 * scroll up. Override this if the child view is a custom view.
 */
protected boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, -1);
    }
}
 
源代码15 项目: stynico   文件: SlidingLayout.java
/**
 * 判断View是否可以上拉
 * @return canChildScrollUp
 */
public boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, -1);
    }
}
 
源代码16 项目: AndroidStudyDemo   文件: SwipyRefreshLayout.java
/**
 * @return Whether it is possible for the child view of this layout to
 * scroll up. Override this if the child view is a custom view.
 */
public boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
源代码17 项目: Swface   文件: PtrDefaultHandler.java
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
源代码18 项目: AssistantBySDK   文件: LingjuSwipeRefreshLayout.java
/**
 * @return Whether it is possible for the child view of this layout to
 * scroll up. Override this if the child view is a custom view.
 */
public boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
源代码19 项目: Android-Application-ZJB   文件: SwipeRefresh.java
/**
 * @return Whether it is possible for the child view of this layout to
 * scroll up. Override this if the child view is a custom view.
 */
public boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
源代码20 项目: CloudReader   文件: SlidingLayout.java
/**
 * 判断View是否可以上拉
 *
 * @return canChildScrollUp
 */
public boolean canChildScrollUp() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, -1);
    }
}