下面列出了android.support.v4.view.ViewCompat#isNestedScrollingEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@VisibleForTesting
View findScrollingChild(View view) {
if (ViewCompat.isNestedScrollingEnabled(view)) {
return view;
} else {
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
int i = 0;
for (int count = group.getChildCount(); i < count; ++i) {
View scrollingChild = this.findScrollingChild(group.getChildAt(i));
if (scrollingChild != null) {
return scrollingChild;
}
}
}
return null;
}
}
@VisibleForTesting
private View findScrollingChild(View view) {
if (ViewCompat.isNestedScrollingEnabled(view)) {
return view;
}
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int i = 0, count = group.getChildCount(); i < count; i++) {
View scrollingChild = findScrollingChild(group.getChildAt(i));
if (scrollingChild != null) {
return scrollingChild;
}
}
}
return null;
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
if ((android.os.Build.VERSION.SDK_INT < 21 && viewTarget instanceof AbsListView) || (viewTarget != null && !ViewCompat.isNestedScrollingEnabled(viewTarget))) {
} else {
super.requestDisallowInterceptTouchEvent(b);
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
View target = mRefreshContent.getScrollableView();
if ((Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView))
&& (target == null || ViewCompat.isNestedScrollingEnabled(target))) {
super.requestDisallowInterceptTouchEvent(b);
//} else {
// Nope.
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
|| (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
// Nope.
} else {
super.requestDisallowInterceptTouchEvent(b);
}
}
public void requestDisallowInterceptTouchEvent(boolean b) {
if (VERSION.SDK_INT < 21 && (this.mTarget instanceof AbsListView)) {
return;
}
if (this.mTarget == null || ViewCompat.isNestedScrollingEnabled(this.mTarget)) {
super.requestDisallowInterceptTouchEvent(b);
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
|| (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
// Nope.
} else {
super.requestDisallowInterceptTouchEvent(b);
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
if ((android.os.Build.VERSION.SDK_INT < 21 && mTargetView instanceof AbsListView)
|| (mTargetView != null && !ViewCompat.isNestedScrollingEnabled(mTargetView))) {
// Nope.
} else {
super.requestDisallowInterceptTouchEvent(b);
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
// if this is a List < L or another view that doesn't support nested
// scrolling, ignore this request so that the vertical scroll event
// isn't stolen
if ((android.os.Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView))
&& (target == null || ViewCompat.isNestedScrollingEnabled(target))) {
super.requestDisallowInterceptTouchEvent(b);
}
}
private void toggleLock() {
mListener.setSwipeEnabled(!mListener.isSwipeEnabled());
if (getView() == null) return;
boolean isNestedScrollingEnabled = ViewCompat.isNestedScrollingEnabled(getView());
ViewCompat.setNestedScrollingEnabled(getView(), !isNestedScrollingEnabled);
}
private void updateLockIcon(@NonNull MenuItem menuItem) {
if (getView() == null) return;
boolean isEnabled = ViewCompat.isNestedScrollingEnabled(getView());
menuItem.setTitle(isEnabled ? UNLOCK : LOCK);
menuItem.setIcon(isEnabled ? mUnlockDrawable : mLockDrawable);
}
private void toggleLock() {
if (getView() == null) return;
boolean isEnabled = ViewCompat.isNestedScrollingEnabled(getView());
ViewCompat.setNestedScrollingEnabled(getView(), !isEnabled);
}