直播商城系统源码,快速滑动条/快速滑块/快速滚动条标准实现
/*
* Copyright 2018 The Android Open Source Project
*
* 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.
*/
package androidx.recyclerview.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.view.MotionEvent;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.ViewCompat;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Class responsible to animate and provide a fast scroller.
*/
@VisibleForTesting
class FastScroller extends RecyclerView.ItemDecoration implements RecyclerView.OnItemTouchListener {
@IntDef({STATE_HIDDEN, STATE_VISIBLE, STATE_DRAGGING})
@Retention(RetentionPolicy.SOURCE)
private @interface State { }
// Scroll thumb not showing
private static final int STATE_HIDDEN = 0;
// Scroll thumb visible and moving along with the scrollbar
private static final int STATE_VISIBLE = 1;
// Scroll thumb being dragged by user
private static final int STATE_DRAGGING = 2;
@IntDef({DRAG_X, DRAG_Y, DRAG_NONE})
@Retention(RetentionPolicy.SOURCE)
private @interface DragState{ }
private static final int DRAG_NONE = 0;
private static final int DRAG_X = 1;
private static final int DRAG_Y = 2;
@IntDef({ANIMATION_STATE_OUT, ANIMATION_STATE_FADING_IN, ANIMATION_STATE_IN,
ANIMATION_STATE_FADING_OUT})
@Retention(RetentionPolicy.SOURCE)
private @interface AnimationState { }
private static final int ANIMATION_STATE_OUT = 0;
private static final int ANIMATION_STATE_FADING_IN = 1;
private static final int ANIMATION_STATE_IN = 2;
private static final int ANIMATION_STATE_FADING_OUT = 3;
private static final int SHOW_DURATION_MS = 500;
private static final int HIDE_DELAY_AFTER_VISIBLE_MS = 1500;
private static final int HIDE_DELAY_AFTER_DRAGGING_MS = 1200;
private static final int HIDE_DURATION_MS = 500;
private static final int SCROLLBAR_FULL_OPAQUE = 255;
private static final int[] PRESSED_STATE_SET = new int[]{android.R.attr.state_pressed};
private static final int[] EMPTY_STATE_SET = new int[]{};
private final int mScrollbarMinimumRange;
private final int mMargin;
// Final values for the vertical scroll bar
@SuppressWarnings("WeakerAccess") /* synthetic access */
final StateListDrawable mVerticalThumbDrawable;
@SuppressWarnings("WeakerAccess") /* synthetic access */
final Drawable mVerticalTrackDrawable;
private final int mVerticalThumbWidth;
private final int mVerticalTrackWidth;
// Final values for the horizontal scroll bar
private final StateListDrawable mHorizontalThumbDrawable;
private final Drawable mHorizontalTrackDrawable;
private final int mHorizontalThumbHeight;
private final int mHorizontalTrackHeight;
// Dynamic values for the vertical scroll bar
@VisibleForTesting int mVerticalThumbHeight;
@VisibleForTesting int mVerticalThumbCenterY;
@VisibleForTesting float mVerticalDragY;
// Dynamic values for the horizontal scroll bar
@VisibleForTesting int mHorizontalThumbWidth;
@VisibleForTesting int mHorizontalThumbCenterX;
@VisibleForTesting float mHorizontalDragX;
private int mRecyclerViewWidth = 0;
private int mRecyclerViewHeight = 0;
private RecyclerView mRecyclerView;
/**
* Whether the document is long/wide enough to require scrolling. If not, we don't show the
* relevant scroller.
*/
private boolean mNeedVerticalScrollbar = false;
private boolean mNeedHorizontalScrollbar = false;
@State private int mState = STATE_HIDDEN;
@DragState private int mDragState = DRAG_NONE;
private final int[] mVerticalRange = new int[2];
private final int[] mHorizontalRange = new int[2];
@SuppressWarnings("WeakerAccess") /* synthetic access */
final ValueAnimator mShowHideAnimator = ValueAnimator.ofFloat(0, 1);
@SuppressWarnings("WeakerAccess") /* synthetic access */
@AnimationState int mAnimationState = ANIMATION_STATE_OUT;
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide(HIDE_DURATION_MS);
}
以上就是 直播商城系统源码,快速滑动条/快速滑块/快速滚动条标准实现,更多内容欢迎关注之后的文章
标签:滑块,int,private,STATE,源码,static,import,快速,final From: https://www.cnblogs.com/yunbaomengnan/p/17787074.html