1 /*
2  * Copyright (C) 2016 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;
25 import com.android.deskclock.R;
26 
27 final class HeaderViewHolder extends ItemAdapter.ItemViewHolder<HeaderHolder> {
28 
29     static final int VIEW_TYPE_ITEM_HEADER = R.layout.ringtone_item_header;
30 
31     private final TextView mItemHeader;
32 
HeaderViewHolder(View itemView)33     private HeaderViewHolder(View itemView) {
34         super(itemView);
35         mItemHeader = (TextView) itemView.findViewById(R.id.ringtone_item_header);
36     }
37 
38     @Override
onBindItemView(HeaderHolder itemHolder)39     protected void onBindItemView(HeaderHolder itemHolder) {
40         mItemHeader.setText(itemHolder.getTextResId());
41     }
42 
43     public static class Factory implements ItemAdapter.ItemViewHolder.Factory {
44 
45         private final LayoutInflater mInflater;
46 
Factory(LayoutInflater inflater)47         Factory(LayoutInflater inflater) {
48             mInflater = inflater;
49         }
50 
51         @Override
createViewHolder(ViewGroup parent, int viewType)52         public ItemAdapter.ItemViewHolder<?> createViewHolder(ViewGroup parent, int viewType) {
53             return new HeaderViewHolder(mInflater.inflate(viewType, parent, false));
54         }
55     }
56 }