1 /*
2  * Copyright (C) 2020 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.deskclock.ringtone
18 
19 import android.view.LayoutInflater
20 import android.view.View
21 import android.view.ViewGroup
22 import android.widget.TextView
23 
24 import com.android.deskclock.ItemAdapter.ItemViewHolder
25 import com.android.deskclock.R
26 
27 internal class HeaderViewHolder private constructor(itemView: View)
28     : ItemViewHolder<HeaderHolder>(itemView) {
29     private val mItemHeader: TextView =
30             itemView.findViewById<View>(R.id.ringtone_item_header) as TextView
31 
onBindItemViewnull32     override fun onBindItemView(itemHolder: HeaderHolder) {
33         mItemHeader.setText(itemHolder.textResId)
34     }
35 
36     class Factory internal constructor(private val mInflater: LayoutInflater)
37         : ItemViewHolder.Factory {
createViewHoldernull38         override fun createViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder<*> {
39             return HeaderViewHolder(mInflater.inflate(viewType, parent, false))
40         }
41     }
42 
43     companion object {
44         const val VIEW_TYPE_ITEM_HEADER = R.layout.ringtone_item_header
45     }
46 }