OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 |
| 6 package org.chromium.content.browser.input; |
| 7 |
| 8 import android.content.Context; |
| 9 import android.text.TextUtils; |
| 10 import android.view.LayoutInflater; |
| 11 import android.view.View; |
| 12 import android.view.ViewGroup; |
| 13 import android.widget.ArrayAdapter; |
| 14 import android.widget.TextView; |
| 15 |
| 16 import org.chromium.content.R; |
| 17 |
| 18 import java.util.List; |
| 19 |
| 20 /** |
| 21 * Date/time suggestion adapter for the suggestion dialog. |
| 22 */ |
| 23 class DateTimeSuggestionListAdapter extends ArrayAdapter<DateTimeSuggestion> { |
| 24 private final Context mContext; |
| 25 |
| 26 DateTimeSuggestionListAdapter(Context context, List<DateTimeSuggestion> obje
cts) { |
| 27 super(context, R.layout.date_time_suggestion, objects); |
| 28 mContext = context; |
| 29 } |
| 30 |
| 31 @Override |
| 32 public View getView(int position, View convertView, ViewGroup parent) { |
| 33 View layout = convertView; |
| 34 if (convertView == null) { |
| 35 LayoutInflater inflater = LayoutInflater.from(mContext); |
| 36 layout = inflater.inflate(R.layout.date_time_suggestion, parent, fal
se); |
| 37 } |
| 38 TextView labelView = (TextView) layout.findViewById(R.id.date_time_sugge
stion_value); |
| 39 TextView sublabelView = (TextView) layout.findViewById(R.id.date_time_su
ggestion_label); |
| 40 |
| 41 if (position == getCount() - 1) { |
| 42 labelView.setText(mContext.getText(R.string.date_picker_dialog_other
_button_label)); |
| 43 sublabelView.setText(""); |
| 44 } else { |
| 45 labelView.setText(getItem(position).localizedValue()); |
| 46 sublabelView.setText(getItem(position).label()); |
| 47 } |
| 48 |
| 49 return layout; |
| 50 } |
| 51 |
| 52 @Override |
| 53 public int getCount() { |
| 54 return super.getCount() + 1; |
| 55 } |
| 56 } |
OLD | NEW |