Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyUrlsAdapter.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyUrlsAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyUrlsAdapter.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ab2cbe7f68b7ae88f8f17ea6bf4ccc64dc4820e9 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/NearbyUrlsAdapter.java |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2015 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.browser.physicalweb; |
| + |
| +import android.content.Context; |
| +import android.view.LayoutInflater; |
| +import android.view.View; |
| +import android.view.ViewGroup; |
| +import android.widget.ArrayAdapter; |
| +import android.widget.ImageView; |
| +import android.widget.TextView; |
| + |
| +import org.chromium.chrome.R; |
| + |
| +/** |
| + * Adapter for displaying nearby URLs and associated metadata. |
| + */ |
| +public class NearbyUrlsAdapter extends ArrayAdapter<PwsResult> { |
|
agrieve
2015/10/22 18:53:07
nit: make package-private?
|
| + |
| + /** |
| + * Construct an empty NearbyUrlsAdapter. |
| + */ |
| + public NearbyUrlsAdapter(Context context) { |
| + super(context, 0); |
| + } |
| + |
| + /** |
| + * Get the view for an item in the data set. |
| + * @param position Index of the list view item within the array. |
| + * @param view The old view to reuse, if possible. |
| + * @param viewGroup The parent that this view will eventually be attached to. |
| + * @return A view corresponding to the list view item. |
| + */ |
| + @Override |
| + public View getView(int position, View view, ViewGroup viewGroup) { |
| + if (view == null) { |
| + LayoutInflater inflater = LayoutInflater.from(getContext()); |
| + view = inflater.inflate(R.layout.physical_web_list_item_nearby_url, viewGroup, false); |
| + } |
| + |
| + TextView titleTextView = (TextView) view.findViewById(R.id.title); |
| + TextView urlTextView = (TextView) view.findViewById(R.id.url); |
| + TextView descriptionTextView = (TextView) view.findViewById(R.id.description); |
| + ImageView iconImageView = (ImageView) view.findViewById(R.id.icon); |
| + |
| + PwsResult pwsResult = getItem(position); |
| + titleTextView.setText(pwsResult.title); |
| + urlTextView.setText(pwsResult.siteUrl); |
| + descriptionTextView.setText(pwsResult.description); |
| + iconImageView.setImageDrawable(null); |
|
dvh
2015/10/22 18:19:10
FYI, you'll probably get as input a Bitmap and the
|
| + |
| + return view; |
| + } |
| +} |