1/*
2 * Copyright (C) 2015 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
17package com.android.tv.dvr.ui;
18
19import android.content.res.Resources;
20import android.graphics.Color;
21import android.support.v17.leanback.widget.Presenter;
22import android.view.Gravity;
23import android.view.ViewGroup;
24import android.widget.TextView;
25
26import com.android.tv.R;
27import com.android.tv.TvApplication;
28import com.android.tv.data.ChannelDataManager;
29import com.android.tv.util.Utils;
30
31/**
32 * Shows the item "NONE".  Used for rows with now items.
33 */
34public class EmptyItemPresenter extends Presenter {
35
36    private final DvrBrowseFragment mMainFragment;
37
38    public EmptyItemPresenter(DvrBrowseFragment mainFragment) {
39        mMainFragment = mainFragment;
40    }
41
42    @Override
43    public ViewHolder onCreateViewHolder(ViewGroup parent) {
44        TextView view = new TextView(parent.getContext());
45        Resources resources = view.getResources();
46        view.setLayoutParams(new ViewGroup.LayoutParams(
47                resources.getDimensionPixelSize(R.dimen.dvr_card_layout_width),
48                resources.getDimensionPixelSize(R.dimen.dvr_card_layout_width)));
49        view.setFocusable(true);
50        view.setFocusableInTouchMode(true);
51        view.setBackgroundColor(
52                Utils.getColor(mMainFragment.getResources(), R.color.setup_background));
53        view.setTextColor(Color.WHITE);
54        view.setGravity(Gravity.CENTER);
55        return new ViewHolder(view);
56    }
57
58    @Override
59    public void onBindViewHolder(ViewHolder viewHolder, Object recording) {
60        ((TextView) viewHolder.view).setText(
61                viewHolder.view.getContext().getString(R.string.dvr_msg_no_recording_on_the_row));
62    }
63
64    @Override
65    public void onUnbindViewHolder(ViewHolder viewHolder) { }
66}
67