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

Unified Diff: chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java

Issue 287293004: [ChromeShell] Add suggestions for ChromeShell toolbar box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed TemplateUrlServiceTest Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java
diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbd147f1e36fdbe0484a17ed3566067aca901dd1
--- /dev/null
+++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/omnibox/SuggestionArrayAdapter.java
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.shell.omnibox;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView.LayoutParams;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import org.chromium.chrome.browser.omnibox.OmniboxSuggestion;
+import org.chromium.chrome.shell.R;
+
+import java.util.List;
+
+/**
+ * Adapter that provides suggestion views for the suggestion popup.
+ */
+class SuggestionArrayAdapter extends ArrayAdapter<OmniboxSuggestion> {
+ private final List<OmniboxSuggestion> mSuggestions;
+
+ public SuggestionArrayAdapter(Context context, int res, List<OmniboxSuggestion> suggestions) {
+ super(context, res, suggestions);
+ mSuggestions = suggestions;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if (v == null) {
+ LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ v = vi.inflate(R.layout.dropdown_item, null);
+ int height = getContext().getResources().getDimensionPixelSize(
+ R.dimen.dropdown_item_height);
+ v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
+ }
+ TextView t1 = (TextView) v.findViewById(R.id.dropdown_label);
+ t1.setText(mSuggestions.get(position).getDisplayText());
+
+ TextView t2 = (TextView) v.findViewById(R.id.dropdown_sublabel);
+ t2.setText(mSuggestions.get(position).getUrl());
+ return v;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698