133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux/*
233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * Copyright (C) 2016 The Android Open Source Project
333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux *
433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * Licensed under the Apache License, Version 2.0 (the "License");
533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * you may not use this file except in compliance with the License.
633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * You may obtain a copy of the License at
733781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux *
833781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux *      http://www.apache.org/licenses/LICENSE-2.0
933781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux *
1033781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * Unless required by applicable law or agreed to in writing, software
1133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * distributed under the License is distributed on an "AS IS" BASIS,
1233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * See the License for the specific language governing permissions and
1433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux * limitations under the License.
1533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux */
1633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
1733781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuxpackage com.android.deskclock.ringtone;
1833781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
1933781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport android.view.LayoutInflater;
2033781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport android.view.View;
2133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport android.view.ViewGroup;
2233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport android.widget.TextView;
2333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
2433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport com.android.deskclock.ItemAdapter;
2533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuximport com.android.deskclock.R;
2633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
2733781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieuxfinal class HeaderViewHolder extends ItemAdapter.ItemViewHolder<HeaderHolder> {
2833781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
2933781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    static final int VIEW_TYPE_ITEM_HEADER = R.layout.ringtone_item_header;
3033781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
3133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    private final TextView mItemHeader;
3233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
3333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    private HeaderViewHolder(View itemView) {
3433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        super(itemView);
3533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        mItemHeader = (TextView) itemView.findViewById(R.id.ringtone_item_header);
3633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    }
3733781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
3833781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    @Override
3933781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    protected void onBindItemView(HeaderHolder itemHolder) {
4033781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        mItemHeader.setText(itemHolder.getTextResId());
4133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    }
4233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
4333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    public static class Factory implements ItemAdapter.ItemViewHolder.Factory {
4433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
4533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        private final LayoutInflater mInflater;
4633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
4733781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        Factory(LayoutInflater inflater) {
4833781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux            mInflater = inflater;
4933781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        }
5033781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux
5133781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        @Override
5233781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        public ItemAdapter.ItemViewHolder<?> createViewHolder(ViewGroup parent, int viewType) {
5333781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux            return new HeaderViewHolder(mInflater.inflate(viewType, parent, false));
5433781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux        }
5533781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux    }
5633781c882e4229f4ec1a8fafbabb9d4b8b8e2932James Lemieux}