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 */
16package com.android.dialer.calllog;
17
18import android.content.Context;
19import android.support.v7.widget.CardView;
20import android.support.v7.widget.RecyclerView;
21import android.view.View;
22
23import com.android.contacts.common.testing.NeededForTesting;
24import com.android.dialer.R;
25
26/**
27 * Generic ViewHolder class for a promo card with a primary and secondary action.
28 * Example: the promo card which appears in the voicemail tab.
29 */
30public class PromoCardViewHolder extends RecyclerView.ViewHolder {
31    public static PromoCardViewHolder create(View rootView) {
32        return new PromoCardViewHolder(rootView);
33    }
34
35    /**
36     * The primary action button view.
37     */
38    private View mPrimaryActionView;
39
40    /**
41     * The secondary action button view.
42     * The "Ok" button view.
43     */
44    private View mSecondaryActionView;
45
46    /**
47     * Creates an instance of the {@link ViewHolder}.
48     *
49     * @param rootView The root view.
50     */
51    private PromoCardViewHolder(View rootView) {
52        super(rootView);
53
54        mPrimaryActionView = rootView.findViewById(R.id.primary_action);
55        mSecondaryActionView = rootView.findViewById(R.id.secondary_action);
56    }
57
58   /**
59     * Retrieves the "primary" action button (eg. "OK").
60     *
61     * @return The view.
62     */
63    public View getPrimaryActionView() {
64        return mPrimaryActionView;
65    }
66
67    /**
68     * Retrieves the "secondary" action button (eg. "Cancel" or "More Info").
69     *
70     * @return The view.
71     */
72    public View getSecondaryActionView() {
73        return mSecondaryActionView;
74    }
75
76    @NeededForTesting
77    public static PromoCardViewHolder createForTest(Context context) {
78        PromoCardViewHolder viewHolder = new PromoCardViewHolder(new View(context));
79        viewHolder.mPrimaryActionView = new View(context);
80        viewHolder.mSecondaryActionView = new View(context);
81        return viewHolder;
82    }
83}
84