1 /*
2  * Copyright (C) 2024 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.wallpaper.picker.customization.ui.view
18 
19 import android.content.Context
20 import android.util.AttributeSet
21 import android.widget.FrameLayout
22 import androidx.recyclerview.widget.RecyclerView
23 import com.android.wallpaper.R
24 import com.android.wallpaper.picker.common.ui.view.ItemSpacing
25 import com.android.wallpaper.picker.customization.ui.view.adapter.FloatingToolbarTabAdapter
26 import com.android.wallpaper.picker.customization.ui.view.animator.TabItemAnimator
27 
28 class FloatingToolbar(
29     context: Context,
30     attrs: AttributeSet?,
31 ) :
32     FrameLayout(
33         context,
34         attrs,
35     ) {
36 
37     private val tabList: RecyclerView
38 
39     init {
40         inflate(context, R.layout.floating_toolbar, this)
41         tabList =
<lambda>null42             requireViewById<RecyclerView>(R.id.tab_list).apply {
43                 itemAnimator = TabItemAnimator()
44                 addItemDecoration(ItemSpacing(TAB_SPACE_DP))
45             }
46     }
47 
setAdapternull48     fun setAdapter(floatingToolbarTabAdapter: FloatingToolbarTabAdapter) {
49         tabList.adapter = floatingToolbarTabAdapter
50     }
51 
52     companion object {
53         const val TAB_SPACE_DP = 4
54     }
55 }
56