예제 #1
0
  protected void newComment() {
    if (commentEditText.getText().toString().length() > 0) {
      if (commentEditText.getText().toString().length() <= 160) {
        String displayName = Application.getDisplayName();
        ParseUser user = ParseUser.getCurrentUser();

        ParseGeoPoint myPoint = geoPointFromLatLng(MainActivity.getLatLng());

        Comment comment = new Comment();
        comment.setAuthor(user);
        comment.setPost(postId);
        comment.setCommentText(commentEditText.getText().toString());
        comment.setDisplayName(displayName);
        comment.setEpochTime();
        comment.setImageURL(imageUrl);
        comment.saveInBackground(
            new SaveCallback() {

              @Override
              public void done(ParseException e) {
                if (e == null) {
                  Toast.makeText(SinglePostView.this, R.string.sent, Toast.LENGTH_SHORT).show();
                  commentEditText.getText().clear();
                  adapter.clear();
                  adapter.loadObjects();
                  adapter.notifyDataSetChanged();
                } else {
                  Toast.makeText(
                          SinglePostView.this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT)
                      .show();
                }
              }
            });
        Log.d(
            TAG,
            "new shout sent of length:"
                + commentEditText.getText().toString().length()
                + commentEditText.getText().toString());
        commentEditText.getText().clear();
      } else {
        Toast.makeText(
                this,
                "The length of your comment is too long: "
                    + commentEditText.getText().length()
                    + "/160",
                Toast.LENGTH_LONG)
            .show();
      }
    } else {
      Toast.makeText(
              this,
              "You have not entered any text! " + commentEditText.getText().length() + "/160",
              Toast.LENGTH_LONG)
          .show();
    }
  }
예제 #2
0
파일: Post.java 프로젝트: chrde/toys
 public void addComment(Comment comment) {
   comments.add(comment);
   comment.setPost(this);
 }