Java tutorial
/** * <pre> * Copyright 2015 Soulwolf Ching * Copyright 2015 The Android Open Source Project for ParallaxScrollView * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </pre> */ package net.soulwolf.widget.parallaxrefresh; import android.os.Build; import android.support.v4.view.ViewCompat; import android.view.View; import android.widget.AbsListView; /** * author: Soulwolf Created on 2015/9/5 0:54. * email : Ching.Soulwolf@gmail.com */ class Utils { static boolean canChildScrollUp(View view) { if (view == null) { return false; } if (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); } } static int minMax(int value, int min, int max) { return Math.max(min, Math.min(value, max)); } static float minMax(float value, float min, float max) { return Math.max(min, Math.min(value, max)); } }