Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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.contacts; |
| 18 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 19 | import android.view.View; |
| 20 | import android.widget.TextView; |
| 21 | |
| 22 | /** |
| 23 | * Encapsulates the views that are used to display the details of a phone call in the call log. |
| 24 | */ |
| 25 | public final class PhoneCallDetailsViews { |
| 26 | public final TextView mNameView; |
| 27 | public final TextView mCallTypeAndDateView; |
| 28 | public final TextView mNumberView; |
| 29 | |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 30 | private PhoneCallDetailsViews(TextView nameView, TextView callTypeAndDateView, |
| 31 | TextView numberView) { |
| 32 | mNameView = nameView; |
| 33 | mCallTypeAndDateView = callTypeAndDateView; |
| 34 | mNumberView = numberView; |
| 35 | } |
| 36 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 37 | /** |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 38 | * Create a new instance by extracting the elements from the given view. |
| 39 | * <p> |
| 40 | * The view should contain three text views with identifiers {@code R.id.name}, |
| 41 | * {@code R.id.call_type}, and {@code R.id.number}. |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 42 | */ |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 43 | public static PhoneCallDetailsViews fromView(View view) { |
| 44 | return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), |
| 45 | (TextView) view.findViewById(R.id.call_type), |
| 46 | (TextView) view.findViewById(R.id.number)); |
| 47 | } |
| 48 | |
| 49 | public static PhoneCallDetailsViews createForTest(TextView nameView, |
| 50 | TextView callTypeAndDateView, TextView numberView) { |
| 51 | return new PhoneCallDetailsViews(nameView, callTypeAndDateView, numberView); |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 52 | } |
Flavio Lerda | afb93bb | 2011-07-05 14:46:10 +0100 | [diff] [blame] | 53 | } |