fixed possible npe and possible exception
This commit is contained in:
parent
ef0bc6714a
commit
8632954e61
|
@ -198,8 +198,12 @@ public class ConversationFragment extends Fragment {
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
if (message.getType() == Message.TYPE_IMAGE) {
|
if (message.getType() == Message.TYPE_IMAGE) {
|
||||||
String[] fileParams = message.getBody().split(",");
|
String[] fileParams = message.getBody().split(",");
|
||||||
|
try {
|
||||||
long size = Long.parseLong(fileParams[0]);
|
long size = Long.parseLong(fileParams[0]);
|
||||||
filesize = size / 1024 + " KB";
|
filesize = size / 1024 + " KB";
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
filesize = "0 KB";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (message.getStatus()) {
|
switch (message.getStatus()) {
|
||||||
case Message.STATUS_UNSEND:
|
case Message.STATUS_UNSEND:
|
||||||
|
@ -585,6 +589,9 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMessages() {
|
public void updateMessages() {
|
||||||
|
if (getView()==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
if (this.conversation != null) {
|
if (this.conversation != null) {
|
||||||
for (Message message : this.conversation.getMessages()) {
|
for (Message message : this.conversation.getMessages()) {
|
||||||
|
|
Loading…
Reference in a new issue