[go: nahoru, domu]

1255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu/*
2255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * Copyright (C) 2015 The Android Open Source Project
3255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu *
4255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * in compliance with the License. You may obtain a copy of the License at
6255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu *
7255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * http://www.apache.org/licenses/LICENSE-2.0
8255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu *
9255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * Unless required by applicable law or agreed to in writing, software distributed under the License
10255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * or implied. See the License for the specific language governing permissions and limitations under
12255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * the License.
13255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu */
14255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gupackage android.support.v17.leanback.app;
15255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu
16255e7911fa9ef664618b74bb9959e00479a9bec1Dake Guimport android.graphics.Color;
17255e7911fa9ef664618b74bb9959e00479a9bec1Dake Guimport android.support.v17.leanback.widget.Presenter;
18255e7911fa9ef664618b74bb9959e00479a9bec1Dake Guimport android.util.Log;
19255e7911fa9ef664618b74bb9959e00479a9bec1Dake Guimport android.view.ViewGroup;
20255e7911fa9ef664618b74bb9959e00479a9bec1Dake Guimport android.widget.TextView;
21255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu
22255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu/**
23255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu * @hide from javadoc
24255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu */
25255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gupublic class StringPresenter extends Presenter {
26255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    private static final boolean DEBUG = false;
27255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    private static final String TAG = "StringPresenter";
28255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu
29255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    @Override
30255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    public ViewHolder onCreateViewHolder(ViewGroup parent) {
31255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        if (DEBUG) Log.d(TAG, "onCreateViewHolder");
32255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        TextView tv = new TextView(parent.getContext());
33255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        tv.setFocusable(true);
34255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        tv.setFocusableInTouchMode(true);
35255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 200));
36255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        tv.setBackgroundColor(Color.CYAN);
37255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        tv.setTextColor(Color.BLACK);
38255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        return new ViewHolder(tv);
39255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    }
40255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu
41255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    @Override
42255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    public void onBindViewHolder(ViewHolder viewHolder, Object item) {
43255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        if (DEBUG) Log.d(TAG, "onBindViewHolder for " + item.toString());
44255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        ((TextView) viewHolder.view).setText(item.toString());
45255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    }
46255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu
47255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    @Override
48255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    public void onUnbindViewHolder(ViewHolder viewHolder) {
49255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu        if (DEBUG) Log.d(TAG, "onUnbindViewHolder");
50255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu    }
51255e7911fa9ef664618b74bb9959e00479a9bec1Dake Gu}
52