Skip to content

Instantly share code, notes, and snippets.

@tolunayozturk
Created September 16, 2020 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolunayozturk/047148b29957e633c599e573aed45489 to your computer and use it in GitHub Desktop.
Save tolunayozturk/047148b29957e633c599e573aed45489 to your computer and use it in GitHub Desktop.
private void commentFile() {
new Thread(new Runnable() {
@Override
public void run() {
try {
if (mAccessToken == null) {
Log.d(TAG, "need to sign in first");
return;
}
if (fileSearched == null) {
Log.d(TAG, "query file first");
return;
}
if (StringUtils.isNullOrEmpty(et_comment.getText().toString())) {
Log.d(TAG, "file name is required to comment");
return;
}
Drive drive = buildDrive();
Comment comment = new Comment();
comment.setDescription(et_comment.getText().toString());
mComment = drive.comments()
.create(fileSearched.getId(), comment)
.setFields("*")
.execute();
if (mComment != null && mComment.getId() != null) {
Log.d(TAG, "add comment success");
} else {
Log.d(TAG, "add comment failed");
}
} catch (Exception e) {
Log.d(TAG, "add comment failed" + e.toString());
}
}
}).start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment