@SuppressLint("SimpleDateFormat")
  @Override
  public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
    StudyRoom studyRoom = StudyRoomGroupManager.getStudyRoomFromCursor(cursor);

    if (view.getId() == android.R.id.text1) {
      TextView tv = (TextView) view;
      tv.setText(studyRoom.name);
    } else if (view.getId() == android.R.id.text2) {
      StringBuilder stringBuilder = new StringBuilder(studyRoom.location).append("<br>");

      if (studyRoom.occupiedTill.compareTo(new Date()) < 0) {
        stringBuilder.append(getString(R.string.free));
      } else {
        stringBuilder
            .append(getString(R.string.occupied))
            .append(" <b>")
            .append(
                new SimpleDateFormat("HH:mm", Locale.getDefault()).format(studyRoom.occupiedTill))
            .append("</b>");
      }

      TextView tv = (TextView) view;
      tv.setText(Utils.fromHtml(stringBuilder.toString()));
    } else if (view.getId() == R.id.text3) {
      TextView tv = (TextView) view;
      tv.setText(studyRoom.code);
    }
    return true;
  }
  /** change presentation of locations in the list */
  @Override
  public boolean setViewValue(View view, Cursor c, int index) {
    if (view.getId() == android.R.id.text2) {
      String transport = c.getString(c.getColumnIndex(Const.TRANSPORT_COLUMN));
      String address = c.getString(c.getColumnIndex(Const.ADDRESS_COLUMN));
      String hours = c.getString(c.getColumnIndex(Const.HOURS_COLUMN));
      String remark = c.getString(c.getColumnIndex(Const.REMARK_COLUMN));
      String room = c.getString(c.getColumnIndex(Const.ROOM_COLUMN));

      StringBuilder sb = new StringBuilder(hours).append('\n').append(address);
      if (!room.isEmpty()) {
        sb.append(", ").append(room);
      }
      if (!transport.isEmpty()) {
        sb.append(" (").append(transport).append(')');
      }
      if (!remark.isEmpty()) {
        sb.append('\n').append(COMPILE.matcher(remark).replaceAll("\n"));
      }
      TextView tv = (TextView) view;
      tv.setText(sb.toString());

      // link email addresses and phone numbers (e.g. 089-123456)
      Linkify.addLinks(tv, Linkify.EMAIL_ADDRESSES);
      Linkify.addLinks(tv, Pattern.compile("[0-9-]{6,}"), "tel:");
      return true;
    } else if (view.getId() == R.id.text3) {
      StringBuilder url = new StringBuilder(c.getString(c.getColumnIndex(Const.URL_COLUMN)));
      TextView tv = (TextView) view;
      if (url.toString().isEmpty()) {
        tv.setVisibility(View.GONE);
      } else {
        url.insert(0, "<a href=\"")
            .append("\">")
            .append(getString(R.string.website))
            .append("</a>");
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        tv.setText(Utils.fromHtml(url.toString()));
      }
      return true;
    }
    return false;
  }