private void sendMessage final String message if recipient null return

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
private void sendMessage(final String message) {
if (recipient == null)
return;
ParseObject object = new ParseObject(ParseUtils.Message.CLASS_NAME);
object.put(ParseUtils.Message.TEXT, message);
object.put(ParseUtils.Message.SENDER, mUser);
object.put(ParseUtils.Message.RECIPIENT, recipient);
object.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
JSONObject data = new JSONObject();
try {
data = new JSONObject()
.put(ParseUtils.Message.TEXT, message)
.put(ParseUtils.Message.SENDER, mUser.getObjectId())
.put(ParseUtils.Message.RECIPIENT, recipientId);
} catch (JSONException ex) {
}
ParsePush push = new ParsePush();
push.setChannel(ParseUtils.Message.CLASS_NAME);
push.setData(data);
push.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
messageEt.setText(null);
} else {
Log.e("push", e.getMessage());
}
}
});
} else {
Log.e("sendMessage", e.getMessage());
}
}
});
addSentMessage(message);
scrollView.post(new Runnable() {
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}