直播商城系统源码,快速滑动条/快速滑块/快速滚动条标准实现

直播商城系统源码,快速滑动条/快速滑块/快速滚动条标准实现

 

1
/*<br> * Copyright 2018 The Android Open Source Project<br> *<br> * Licensed under the Apache License, Version 2.0 (the "License");<br> * you may not use this file except in compliance with the License.<br> * You may obtain a copy of the License at<br> *<br> *      http://www.apache.org/licenses/LICENSE-2.0<br> *<br> * Unless required by applicable law or agreed to in writing, software<br> * distributed under the License is distributed on an "AS IS" BASIS,<br> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br> * See the License for the specific language governing permissions and<br> * limitations under the License.<br> */<br>package androidx.recyclerview.widget;<br>import android.animation.Animator;<br>import android.animation.AnimatorListenerAdapter;<br>import android.animation.ValueAnimator;<br>import android.animation.ValueAnimator.AnimatorUpdateListener;<br>import android.graphics.Canvas;<br>import android.graphics.drawable.Drawable;<br>import android.graphics.drawable.StateListDrawable;<br>import android.view.MotionEvent;<br>import androidx.annotation.IntDef;<br>import androidx.annotation.NonNull;<br>import androidx.annotation.Nullable;<br>import androidx.annotation.VisibleForTesting;<br>import androidx.core.view.ViewCompat;<br>import java.lang.annotation.Retention;<br>import java.lang.annotation.RetentionPolicy;<br>/**<br> * Class responsible to animate and provide a fast scroller.<br> */<br>@VisibleForTesting<br>class FastScroller extends RecyclerView.ItemDecoration implements RecyclerView.OnItemTouchListener {<br>    @IntDef({STATE_HIDDEN, STATE_VISIBLE, STATE_DRAGGING})<br>    @Retention(RetentionPolicy.SOURCE)<br>    private @interface State { }<br>    // Scroll thumb not showing<br>    private static final int STATE_HIDDEN = 0;<br>    // Scroll thumb visible and moving along with the scrollbar<br>    private static final int STATE_VISIBLE = 1;<br>    // Scroll thumb being dragged by user<br>    private static final int STATE_DRAGGING = 2;<br>    @IntDef({DRAG_X, DRAG_Y, DRAG_NONE})<br>    @Retention(RetentionPolicy.SOURCE)<br>    private @interface DragState{ }<br>    private static final int DRAG_NONE = 0;<br>    private static final int DRAG_X = 1;<br>    private static final int DRAG_Y = 2;<br>    @IntDef({ANIMATION_STATE_OUT, ANIMATION_STATE_FADING_IN, ANIMATION_STATE_IN,<br>        ANIMATION_STATE_FADING_OUT})<br>    @Retention(RetentionPolicy.SOURCE)<br>    private @interface AnimationState { }<br>    private static final int ANIMATION_STATE_OUT = 0;<br>    private static final int ANIMATION_STATE_FADING_IN = 1;<br>    private static final int ANIMATION_STATE_IN = 2;<br>    private static final int ANIMATION_STATE_FADING_OUT = 3;<br>    private static final int SHOW_DURATION_MS = 500;<br>    private static final int HIDE_DELAY_AFTER_VISIBLE_MS = 1500;<br>    private static final int HIDE_DELAY_AFTER_DRAGGING_MS = 1200;<br>    private static final int HIDE_DURATION_MS = 500;<br>    private static final int SCROLLBAR_FULL_OPAQUE = 255;<br>    private static final int[] PRESSED_STATE_SET = new int[]{android.R.attr.state_pressed};<br>    private static final int[] EMPTY_STATE_SET = new int[]{};<br>    private final int mScrollbarMinimumRange;<br>    private final int mMargin;<br>    // Final values for the vertical scroll bar<br>    @SuppressWarnings("WeakerAccess") /* synthetic access */<br>    final StateListDrawable mVerticalThumbDrawable;<br>    @SuppressWarnings("WeakerAccess") /* synthetic access */<br>    final Drawable mVerticalTrackDrawable;<br>    private final int mVerticalThumbWidth;<br>    private final int mVerticalTrackWidth;<br>    // Final values for the horizontal scroll bar<br>    private final StateListDrawable mHorizontalThumbDrawable;<br>    private final Drawable mHorizontalTrackDrawable;<br>    private final int mHorizontalThumbHeight;<br>    private final int mHorizontalTrackHeight;<br>    // Dynamic values for the vertical scroll bar<br>    @VisibleForTesting int mVerticalThumbHeight;<br>    @VisibleForTesting int mVerticalThumbCenterY;<br>    @VisibleForTesting float mVerticalDragY;<br>    // Dynamic values for the horizontal scroll bar<br>    @VisibleForTesting int mHorizontalThumbWidth;<br>    @VisibleForTesting int mHorizontalThumbCenterX;<br>    @VisibleForTesting float mHorizontalDragX;<br>    private int mRecyclerViewWidth = 0;<br>    private int mRecyclerViewHeight = 0;<br>    private RecyclerView mRecyclerView;<br>    /**<br>     * Whether the document is long/wide enough to require scrolling. If not, we don't show the<br>     * relevant scroller.<br>     */<br>    private boolean mNeedVerticalScrollbar = false;<br>    private boolean mNeedHorizontalScrollbar = false;<br>    @State private int mState = STATE_HIDDEN;<br>    @DragState private int mDragState = DRAG_NONE;<br>    private final int[] mVerticalRange = new int[2];<br>    private final int[] mHorizontalRange = new int[2];<br>    @SuppressWarnings("WeakerAccess") /* synthetic access */<br>    final ValueAnimator mShowHideAnimator = ValueAnimator.ofFloat(0, 1);<br>    @SuppressWarnings("WeakerAccess") /* synthetic access */<br>    @AnimationState int mAnimationState = ANIMATION_STATE_OUT;<br>    private final Runnable mHideRunnable = new Runnable() {<br>        @Override<br>        public void run() {<br>            hide(HIDE_DURATION_MS);<br>        }

 以上就是 直播商城系统源码,快速滑动条/快速滑块/快速滚动条标准实现,更多内容欢迎关注之后的文章

 

posted @   云豹科技-苏凌霄  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2022-10-25 直播平台搭建源码,react+ts实现分页全部功能
2022-10-25 直播app开发搭建,两种很简单的网页特效实现
2022-10-25 直播带货源码,如何用Android Studio实现登录跳转
2021-10-25 直播系统代码,输入时实现密码显示与隐藏
2021-10-25 短视频平台源码,Android 左右滑动显示和隐藏
2021-10-25 一对一直播源码,实现Button按下后颜色加深的效果
点击右上角即可分享
微信分享提示