public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    if (convertView == null) vi = inflater.inflate(R.layout.droplet_list_row, null);

    final Droplet droplet = data.get(position);
    Region region = droplet.getRegion();
    Image image = droplet.getImage();

    TextView nameTextView = (TextView) vi.findViewById(R.id.nameTextView);
    TextView ipAddressTextView = (TextView) vi.findViewById(R.id.ipAddressTextView);
    TextView statusTextView = (TextView) vi.findViewById(R.id.statusTextView);
    ImageView distroImageView = (ImageView) vi.findViewById(R.id.distroImageView);
    ImageView flagImageView = (ImageView) vi.findViewById(R.id.flagImageView);
    if (region != null) flagImageView.setImageResource(ApiHelper.getLocationFlag(region.getName()));
    else flagImageView.setVisibility(View.GONE);

    if (image != null)
      distroImageView.setImageResource(
          ApiHelper.getDistributionLogo(image.getDistribution(), droplet.getStatus()));

    nameTextView.setText(droplet.getName());
    ipAddressTextView.setText(droplet.getIpAddress());
    statusTextView.setText(droplet.getStatus());

    return vi;
  }
 public long create(Image image) {
   ContentValues values = new ContentValues();
   values.put(ImageTable.ID, image.getId());
   values.put(ImageTable.NAME, image.getName());
   values.put(ImageTable.DISTRIBUTION, image.getDistribution());
   values.put(ImageTable.SLUG, image.getSlug());
   values.put(ImageTable.PUBLIC, image.isPublic() ? 1 : 0);
   long id =
       db.insertWithOnConflict(
           getTableHelper().TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
   return id;
 }
 public Image newInstance(Cursor c) {
   Image image = new Image();
   image.setId(c.getLong(c.getColumnIndex(ImageTable.ID)));
   image.setName(c.getString(c.getColumnIndex(ImageTable.NAME)));
   image.setDistribution(c.getString(c.getColumnIndex(ImageTable.DISTRIBUTION)));
   image.setSlug(c.getString(c.getColumnIndex(ImageTable.SLUG)));
   image.setPublic(c.getInt(c.getColumnIndex(ImageTable.PUBLIC)) > 0);
   return image;
 }