Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/DateTimeSuggestionListAdapter.java

Issue 23623019: Support datalist for date/time input types on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
newt (away) 2013/10/09 07:20:52 remove blank line
6 package org.chromium.ui.autofill; 6 package org.chromium.content.browser.input;
7 7
8 import android.content.Context; 8 import android.content.Context;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 10
newt (away) 2013/10/09 07:20:52 remove blank line
11 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
12 import android.view.View; 12 import android.view.View;
13 import android.view.ViewGroup; 13 import android.view.ViewGroup;
14 import android.widget.ArrayAdapter; 14 import android.widget.ArrayAdapter;
15 import android.widget.TextView; 15 import android.widget.TextView;
16 16
17 import org.chromium.ui.R; 17 import org.chromium.content.R;
18 18
19 import java.util.ArrayList; 19 import java.util.ArrayList;
20 20
21 /** 21 /**
22 * Autofill suggestion adapter for AutofillWindow. 22 * Autofill suggestion adapter for AutofillWindow.
Miguel Garcia 2013/10/08 17:44:40 please fix doc
23 */ 23 */
24 public class AutofillListAdapter extends ArrayAdapter<AutofillSuggestion> { 24 public class DateTimeSuggestionListAdapter extends ArrayAdapter<DateTimeSuggesti on> {
25 private Context mContext; 25 private Context mContext;
26 26
27 AutofillListAdapter(Context context, ArrayList<AutofillSuggestion> objects) { 27 DateTimeSuggestionListAdapter(Context context, ArrayList<DateTimeSuggestion> objects) {
28 super(context, R.layout.autofill_text, objects); 28 super(context, R.layout.date_time_suggestion_item, objects);
29 mContext = context; 29 mContext = context;
30 } 30 }
31 31
32 @Override 32 @Override
33 public View getView(int position, View convertView, ViewGroup parent) { 33 public View getView(int position, View convertView, ViewGroup parent) {
34 View layout = convertView; 34 View layout = convertView;
35 if (convertView == null) { 35 if (convertView == null) {
36 LayoutInflater inflater = 36 LayoutInflater inflater =
newt (away) 2013/10/09 07:20:52 LayoutInflater inflater = LayoutInflater.from(mCon
keishi 2013/10/21 17:00:58 Done.
37 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE); 37 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
38 layout = inflater.inflate(R.layout.autofill_text, null); 38 layout = inflater.inflate(R.layout.date_time_suggestion_item, null);
newt (away) 2013/10/09 07:20:52 do this: layout = inflater.inflate(R.layout.d
39 } 39 }
40 TextView labelView = (TextView) layout.findViewById(R.id.autofill_label) ; 40 TextView labelView = (TextView) layout.findViewById(R.id.date_time_sugge stion_value);
41 labelView.setText(getItem(position).mLabel); 41 TextView sublabelView = (TextView) layout.findViewById(R.id.date_time_su ggestion_label);
42 42
43 TextView sublabelView = (TextView) layout.findViewById(R.id.autofill_sub label); 43 if (position == getCount() - 1) {
44 CharSequence sublabel = getItem(position).mSublabel; 44 labelView.setText(mContext.getText(R.string.date_picker_dialog_other _item_label));
45 if (TextUtils.isEmpty(sublabel)) { 45 sublabelView.setText("");
46 sublabelView.setVisibility(View.GONE);
47 } else { 46 } else {
48 sublabelView.setText(sublabel); 47 labelView.setText(getItem(position).mLocalizedValue);
49 sublabelView.setVisibility(View.VISIBLE); 48 sublabelView.setText(getItem(position).mLabel);
50 } 49 }
51 50
52 return layout; 51 return layout;
53 } 52 }
53
54 @Override
55 public int getCount() {
56 return super.getCount() + 1;
Miguel Garcia 2013/10/08 17:44:40 why +1? getCount should give you the actual size r
57 }
54 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698