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

Side by Side 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: Fixed Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(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 package org.chromium.ui;
6
7 import android.content.Context;
8 import android.graphics.drawable.GradientDrawable;
9 import android.graphics.drawable.LayerDrawable;
10 import android.view.LayoutInflater;
11 import android.view.View;
12 import android.view.ViewGroup;
13 import android.widget.ArrayAdapter;
14 import android.widget.GridView;
15
16 import java.util.ArrayList;
17
18 public class ColorGridAdapter extends ArrayAdapter<ColorSuggestion> {
19 private Context mContext;
20
21 ColorGridAdapter(Context context, ArrayList<ColorSuggestion> suggestions) {
22 super(context, R.layout.color_button, suggestions);
23 mContext = context;
24 }
25
26 @Override
27 public View getView(int position, View convertView, ViewGroup parent) {
28 View layout = convertView;
29 if (convertView == null) {
30 LayoutInflater inflater =
31 (LayoutInflater) mContext.getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
32 layout = inflater.inflate(R.layout.color_button, null);
33 layout.setLayoutParams(new GridView.LayoutParams(60, 60));
newt (away) 2013/08/29 05:35:33 you're actually respecifying the width and height
34 }
35 ColorSuggestion suggestion = getItem(position);
36 LayerDrawable background = (LayerDrawable)layout.getBackground();
newt (away) 2013/08/29 05:35:33 space before "layout"
37 GradientDrawable swatch =
38 (GradientDrawable) background.findDrawableByLayerId(R.id.color_b utton_swatch);
newt (away) 2013/08/29 05:35:33 where is color_button_swatch defined?
39 swatch.setColor(suggestion.mColor);
40 String description = suggestion.mLabel;
41 if (description.isEmpty())
newt (away) 2013/08/29 05:35:33 need curly braces in Java. also, could description
42 description = String.format("#%06X", (0xFFFFFF & suggestion.mColor)) ;
43 layout.setContentDescription(description);
44 return layout;
45 }
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698