/*
   * (non-Javadoc)
   *
   * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
   */
  @SuppressLint("NewApi")
  @SuppressWarnings("deprecation")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
      /*
       * TODO: build the layout programmatically
       */
      view = mLayoutInflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_field, null);
    }

    // set the background to a colored circle
    // TODO: allow to customize the shape
    Shape shape = new ArcShape(0, 360);
    ShapeDrawable bg = new ShapeDrawable(shape);
    bg.getPaint().setColor(mPalette.getColor(position));

    if (android.os.Build.VERSION.SDK_INT < 16) {
      view.setBackgroundDrawable(bg);
    } else {
      view.setBackground(bg);
    }

    return view;
  }
 /*
  * (non-Javadoc)
  *
  * @see android.widget.Adapter#getCount()
  */
 @Override
 public int getCount() {
   return mPalette.getNumberOfColors();
 }
 /*
  * (non-Javadoc)
  *
  * @see android.widget.Adapter#getItem(int)
  */
 @Override
 public Object getItem(int position) {
   return mPalette.getColor(position);
 }
 public int getNumColumns() {
   return mPalette.getNumberOfColumns();
 }