1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.car.apps.common.util;
18 
19 import android.content.Context;
20 
21 import androidx.recyclerview.widget.RecyclerView;
22 
23 import com.android.car.apps.common.widget.PagedRecyclerView;
24 import com.android.car.apps.common.widget.PagedRecyclerView.ScrollBarPosition;
25 
26 /**
27  * An abstract class that defines required contract for a custom scroll bar for the
28  * {@link PagedRecyclerView}. All custom scroll bar must inherit from this class.
29  */
30 public abstract class ScrollBarUI {
31     protected RecyclerView mRecyclerView;
32 
getRecyclerView()33     public RecyclerView getRecyclerView() {
34         return mRecyclerView;
35     }
36 
37     /**
38      * The concrete class should implement this method to initialize configuration of a scrollbar
39      * view.
40      */
initialize(Context context, RecyclerView recyclerView, int scrollBarContainerWidth, @ScrollBarPosition int scrollBarPosition, boolean scrollBarAboveRecyclerView)41     public abstract void initialize(Context context, RecyclerView recyclerView,
42             int scrollBarContainerWidth, @ScrollBarPosition int scrollBarPosition,
43             boolean scrollBarAboveRecyclerView);
44 
45     /**
46      * Requests layout of the scrollbar. Should be called when there's been a change that will
47      * affect the size of the scrollbar view.
48      */
requestLayout()49     public abstract void requestLayout();
50 
51     /**
52      * Sets the padding of the scrollbar, relative to the padding of the RecyclerView.
53      */
setPadding(int padddingStart, int paddingEnd)54     public abstract void setPadding(int padddingStart, int paddingEnd);
55 }
56