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

Unified Diff: ui/android/java/src/org/chromium/ui/ColorGridAdapter.java

Issue 23026006: Add support for color input datalist on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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: ui/android/java/src/org/chromium/ui/ColorGridAdapter.java
diff --git a/ui/android/java/src/org/chromium/ui/ColorGridAdapter.java b/ui/android/java/src/org/chromium/ui/ColorGridAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..9541a44a2147d085c0c1f3c06ecd37a15cc86b71
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/ColorGridAdapter.java
@@ -0,0 +1,41 @@
+// Copyright 2013 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.ui;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.GridView;
+
+import java.util.ArrayList;
+
+public class ColorGridAdapter extends ArrayAdapter<ColorSuggestion> {
+ private Context mContext;
+
+ ColorGridAdapter(Context context, ArrayList<ColorSuggestion> suggestions) {
+ super(context, R.layout.color_button, suggestions);
+ mContext = context;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View layout = convertView;
+ if (convertView == null) {
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ layout = inflater.inflate(R.layout.color_button, null);
+ }
+ View swatch = layout.findViewById(R.id.color_button_swatch);
+ ColorSuggestion suggestion = getItem(position);
+ swatch.setBackgroundColor(suggestion.mValueAsColor);
+ String description = suggestion.mLabel;
+ if (description.isEmpty())
+ description = suggestion.mValueAsText;
+ layout.setContentDescription(description);
+ return layout;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698