@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
      convertView = LayoutInflater.from(mContext).inflate(R.layout.message_item, null);
      holder = new ViewHolder();
      holder.iconImageView = (ImageView) convertView.findViewById(R.id.messageIcon);
      holder.nameLabel = (TextView) convertView.findViewById(R.id.senderLabel);
      holder.timeLabel = (TextView) convertView.findViewById(R.id.timeLabel);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    ParseObject message = mMessages.get(position);
    Date createdAt = message.getCreatedAt();
    long now = new Date().getTime();
    String convertedDate =
        DateUtils.getRelativeTimeSpanString(createdAt.getTime(), now, DateUtils.SECOND_IN_MILLIS)
            .toString();

    if (message.getString(ParseConstants.KEY_FILE_TYPE).equals(ParseConstants.TYPE_IMAGE)) {
      holder.iconImageView.setImageResource(R.drawable.ic_picture);
    } else {
      holder.iconImageView.setImageResource(R.drawable.ic_video);
    }
    holder.nameLabel.setText(message.getString(ParseConstants.KEY_SENDER_NAME));
    holder.timeLabel.setText(convertedDate);

    return convertView;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final boolean customTitle = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    final Intent i = new Intent(this, BuganizerCreateParseUserActivity.class);

    setContentView(R.layout.bug_edit);

    if (customTitle) {
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_layout);
    }

    TextView tt = (TextView) findViewById(R.id.logout);
    tt.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Log.d("BuganizerParseEdit", "logout clicked ");
            ParseUser.logOut();
            startActivity(i);
          }
        });

    arrayPeople = new ArrayList<String>();

    mLinLayout = (LinearLayout) findViewById(R.id.EditVertLayout);

    Button bsave = (Button) findViewById(R.id.BugSave);
    Button bAddComment = (Button) findViewById(R.id.AddComment);
    Button bAddFriend = (Button) findViewById(R.id.AddUser);

    Log.d("BuganizerParseEdit", "hare krsna showing bug details ");

    Bundle extras = getIntent().getExtras();

    if (extras != null) {

      objectid = extras.getString(BuganizerParseConstants.objectid);
      Log.d("BuganizerParseEdit", "object id is  " + objectid);

      ParseQuery query = new ParseQuery("BugObject");
      try {
        pObject = query.get(objectid);
      } catch (ParseException e1) {
        e1.printStackTrace();
      }

      mAssTo = (TextView) findViewById(R.id.EditBugAssignedTo);
      mDetails = (TextView) findViewById(R.id.EditBugDetails);
      mTitle = (TextView) findViewById(R.id.EditBugTitle);
      mCreatedTS = (TextView) findViewById(R.id.EditBugCreatedTS);
      mPriority = (TextView) findViewById(R.id.EditBugPriority);
      mLayout = (LinearLayout) findViewById(R.id.EditVertLayout);

      String title = pObject.getString(BuganizerParseConstants.title);
      String body = pObject.getString(BuganizerParseConstants.body);
      String assto = pObject.getString(BuganizerParseConstants.assignedto);
      Date ts2 = pObject.getCreatedAt();
      int pri = pObject.getInt(BuganizerParseConstants.priority);

      acl = pObject.getACL();

      SimpleDateFormat dateFormatISO8601 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

      String ts = dateFormatISO8601.format(ts2);

      if (title != null) {
        mTitle.setText(title);
      }
      if (body != null) {
        mDetails.setText(body);
      }
      if (assto != null) {
        mAssTo.setText(assto);
      }
      if (ts != null) {
        mCreatedTS.setText(ts);
      }
      if (pri != 0) {
        mPriority.setText(Integer.toString(pri));
      } else {
        mPriority.setText("undefined");
      }

      if (acl != null) {
        Log.d("BuganizerParseEdit", "The bug has an ACL!");
        if (acl.getWriteAccess(ParseUser.getCurrentUser()) == true) {
          CheckBox chk = new CheckBox(this);
          chk.setChecked(true);
          chk.setText("Mark as private");
          mLayout.addView(chk, 5);
        }
      }
    }

    GetCommentsForBug();

    // fetch the comments first in the background
    ParseQuery query = new ParseQuery("CommentObject");
    query.whereEqualTo("bug", pObject);
    query.findInBackground(
        new FindCallback() {

          @Override
          public void done(List<ParseObject> objects, ParseException arg1) {

            // TODO Auto-generated method stub
            for (ParseObject ob : objects) {
              Log.d(
                  "BuganizerParseEdit",
                  "comments are : "
                      + ob.getString(BuganizerParseConstants.comments)
                      + " created at TS: "
                      + ob.getCreatedAt());
              AddCommentView(ob.getString(BuganizerParseConstants.comments), "", "", false);
            }
          }
        });

    bAddComment.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Log.d("BuganizerParseEdit", "Adding a new comment... ");
            final EditText bdetails = (EditText) findViewById(R.id.BugCommentAdd);
            String cmnt = bdetails.getText().toString();

            arrayPeople.add(cmnt);
            bdetails.setText("");
            AddCommentView(cmnt, "", "", false);
          }
        });

    bAddFriend.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Log.d("BuganizerParseEdit", "Adding a user to bug... ");
            Intent i2 = new Intent(BuganizerParseEdit.this, BuganizerListFriendsActivity.class);
            BuganizerParseEdit.this.startActivityForResult(i2, ACTIVITY_FRIEND_LIST_SHOW);
          }
        });

    bsave.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            Intent mIntent = new Intent();
            Bundle bundle = new Bundle();

            for (String s : arrayPeople) Log.d("BuganizerParseEdit", "Comment: " + s);

            bundle.putString(BuganizerParseConstants.objectid, objectid);
            bundle.putStringArrayList(BuganizerParseConstants.comments, arrayPeople);

            mIntent.putExtras(bundle);
            setResult(RESULT_OK, mIntent);
            finish();
          }
        });
  }