mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Guard against empty strings in shared story content.
This commit is contained in:
parent
3e19821489
commit
65b1f68dde
1 changed files with 14 additions and 7 deletions
|
@ -139,6 +139,8 @@ public class InteractionsAdapter extends ActivityDetailsAdapter {
|
|||
private CharSequence getSharedStoryContent(ActivityDetails activity) {
|
||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||
int usernameLength;
|
||||
int reSharedLength = 0;
|
||||
int titleLength = 0;
|
||||
if (activity.user != null) {
|
||||
usernameLength = activity.user.username.length();
|
||||
stringBuilder.append(activity.user.username);
|
||||
|
@ -147,20 +149,25 @@ public class InteractionsAdapter extends ActivityDetailsAdapter {
|
|||
stringBuilder.append(UNKNOWN_USERNAME);
|
||||
}
|
||||
stringBuilder.append(" ");
|
||||
stringBuilder.append(reshared);
|
||||
stringBuilder.append(" ");
|
||||
stringBuilder.append(activity.title);
|
||||
stringBuilder.append(" ");
|
||||
if (!TextUtils.isEmpty(reshared)) {
|
||||
stringBuilder.append(reshared);
|
||||
stringBuilder.append(" ");
|
||||
reSharedLength = reshared.length();
|
||||
}
|
||||
if (!TextUtils.isEmpty(activity.title)) {
|
||||
stringBuilder.append(activity.title);
|
||||
stringBuilder.append(" ");
|
||||
titleLength = activity.title.length();
|
||||
}
|
||||
if (!TextUtils.isEmpty(activity.content)) {
|
||||
stringBuilder.append("\n\n\"");
|
||||
stringBuilder.append(activity.content);
|
||||
stringBuilder.append("\"");
|
||||
}
|
||||
|
||||
int titleSpanStart = usernameLength + 1 + reshared.length() + 1;
|
||||
int titleLength = activity.title.length();
|
||||
int titleSpanStart = usernameLength + 1 + reSharedLength + 1;
|
||||
stringBuilder.setSpan(linkColor, 0, titleSpanStart + titleLength, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
stringBuilder.setSpan(contentColor, usernameLength + 1, usernameLength + 1 + reshared.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
stringBuilder.setSpan(contentColor, usernameLength + 1, usernameLength + 1 + reSharedLength, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
if (!TextUtils.isEmpty(activity.content)) {
|
||||
stringBuilder.setSpan(quoteColor, stringBuilder.length() - activity.content.length() - 2, stringBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
|
Loading…
Add table
Reference in a new issue