Exemplo n.º 1
0
 private int getColor(Note note) {
   double max = Integer.MAX_VALUE;
   double universe = max - (double) Integer.MIN_VALUE;
   double randomish = (max - note.hashCode()) / universe;
   int index = (int) (randomish * COLORS.length);
   return Color.parseColor(COLORS[index]);
 }
Exemplo n.º 2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Note note = this.getItem(position);
    View row = convertView;

    if (row == null) {
      LayoutInflater inflater = LayoutInflater.from(this.context);
      row = inflater.inflate(R.layout.listview_notes, parent, false);
    }

    View flash = (View) row.findViewById(R.id.listnote_flash);
    flash.setBackgroundColor(this.getColor(note));

    TextView name = (TextView) row.findViewById(R.id.listnote_name);
    name.setText(note.getName());

    TextView text = (TextView) row.findViewById(R.id.listnote_text);
    text.setText(note.getTextSummary());

    TextView lastModified = (TextView) row.findViewById(R.id.listnode_lastModified);

    String date = DateTime.formatDate(note.getLastModified());
    date += "\n" + DateTime.formatTime(note.getLastModified());
    lastModified.setText(date);

    TextView size = (TextView) row.findViewById(R.id.listnote_size);
    size.setText(note.getSizeString());

    row.setTag(note);

    return row;
  }