Skip to content

Commit

Permalink
crash on null message body
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Jun 17, 2022
1 parent 158d354 commit 83d8eba
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions app/src/main/java/co/tinode/tindroid/MessagesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,21 +568,23 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
boolean uploadingAttachment = hasAttachment && m.isPending();
boolean uploadFailed = hasAttachment && (m.status == BaseDb.Status.FAILED);

// Disable clicker while message is processed.
FullFormatter formatter = new FullFormatter(holder.mText, uploadingAttachment ? null : new SpanClicker(m.seq));
formatter.setQuoteFormatter(new QuoteFormatter(holder.mText, holder.mText.getTextSize()));
Spanned text = m.content.format(formatter);
if (text == null || text.length() == 0) {
if (m.status == BaseDb.Status.DRAFT || m.status == BaseDb.Status.QUEUED || m.status == BaseDb.Status.SENDING) {
text = serviceContentSpanned(mActivity, R.drawable.ic_schedule_gray, R.string.processing);
} else if (m.status == BaseDb.Status.FAILED) {
text = serviceContentSpanned(mActivity, R.drawable.ic_error_gray, R.string.failed);
} else {
text = serviceContentSpanned(mActivity, R.drawable.ic_warning_gray, R.string.invalid_content);
if (m.content != null) {
// Disable clicker while message is processed.
FullFormatter formatter = new FullFormatter(holder.mText, uploadingAttachment ? null : new SpanClicker(m.seq));
formatter.setQuoteFormatter(new QuoteFormatter(holder.mText, holder.mText.getTextSize()));
Spanned text = m.content.format(formatter);
if (TextUtils.isEmpty(text)) {
if (m.status == BaseDb.Status.DRAFT || m.status == BaseDb.Status.QUEUED || m.status == BaseDb.Status.SENDING) {
text = serviceContentSpanned(mActivity, R.drawable.ic_schedule_gray, R.string.processing);
} else if (m.status == BaseDb.Status.FAILED) {
text = serviceContentSpanned(mActivity, R.drawable.ic_error_gray, R.string.failed);
} else {
text = serviceContentSpanned(mActivity, R.drawable.ic_warning_gray, R.string.invalid_content);
}
}
holder.mText.setText(text);
}

holder.mText.setText(text);
if (m.content != null && m.content.hasEntities(Arrays.asList("AU", "BN", "LN", "MN", "HT", "IM", "EX"))) {
// Some spans are clickable.
holder.mText.setOnTouchListener((v, ev) -> {
Expand Down

0 comments on commit 83d8eba

Please sign in to comment.