From 79ea126fec5c8f00538b91426206e0b3629fdbfa Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 1 Jun 2016 12:50:38 +0800 Subject: [PATCH] hides status text when it's empty --- .../twidere/fragment/StatusFragment.java | 30 ++++++++--------- .../twidere/view/holder/StatusViewHolder.java | 32 +++++++++---------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/StatusFragment.java index 3a1953362..c72faefae 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/StatusFragment.java @@ -1027,18 +1027,17 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac ParcelableStatusUtils.applySpans(quotedText, status.quoted_spans); linkify.applyAllLinks(quotedText, status.account_key, layoutPosition, status.is_possibly_sensitive, skipLinksInText); - if (quotedDisplayEnd == 0 || quotedText.length() == 0) { - // No text - final SpannableString string = SpannableString.valueOf(context.getString(R.string.no_status_content_text)); - string.setSpan(new ForegroundColorSpan(ThemeUtils.getColorFromAttribute(context, - android.R.attr.textColorTertiary, textView.getCurrentTextColor())), 0, - string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - quotedTextView.setText(string); - } else if (quotedDisplayEnd != -1 && quotedDisplayEnd <= quotedText.length()) { + if (quotedDisplayEnd != -1 && quotedDisplayEnd <= quotedText.length()) { quotedTextView.setText(quotedText.subSequence(0, quotedDisplayEnd)); } else { quotedTextView.setText(quotedText); } + if (quotedTextView.length() == 0) { + // No text + quotedTextView.setVisibility(View.GONE); + } else { + quotedTextView.setVisibility(View.VISIBLE); + } quoteIndicator.setColor(status.quoted_user_color); } else { @@ -1111,18 +1110,17 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac linkify.applyAllLinks(text, status.account_key, layoutPosition, status.is_possibly_sensitive, skipLinksInText); - if (displayEnd == 0 || text.length() == 0) { - // No text - final SpannableString string = SpannableString.valueOf(context.getString(R.string.no_status_content_text)); - string.setSpan(new ForegroundColorSpan(ThemeUtils.getColorFromAttribute(context, - android.R.attr.textColorTertiary, textView.getCurrentTextColor())), 0, - string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - textView.setText(string); - } else if (displayEnd != -1 && displayEnd <= text.length()) { + if (displayEnd != -1 && displayEnd <= text.length()) { textView.setText(text.subSequence(0, displayEnd)); } else { textView.setText(text); } + if (textView.length() == 0) { + // No text + textView.setVisibility(View.GONE); + } else { + textView.setVisibility(View.VISIBLE); + } final ParcelableLocation location; final String placeFullName; diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java index 568674f77..45780215f 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java @@ -288,19 +288,19 @@ public class StatusViewHolder extends ViewHolder implements Constants, IStatusVi } else { quotedText = status.quoted_text_unescaped; } - if (quotedDisplayEnd == 0 || quotedText.length() == 0) { - // No text - final SpannableString string = SpannableString.valueOf(context.getString(R.string.no_status_content_text)); - string.setSpan(new ForegroundColorSpan(ThemeUtils.getColorFromAttribute(context, - android.R.attr.textColorTertiary, textView.getCurrentTextColor())), 0, - string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - quotedTextView.setText(string); - } else if (quotedDisplayEnd != -1 && quotedDisplayEnd <= quotedText.length()) { + if (quotedDisplayEnd != -1 && quotedDisplayEnd <= quotedText.length()) { quotedTextView.setText(quotedText.subSequence(0, quotedDisplayEnd)); } else { quotedTextView.setText(quotedText); } + if (quotedTextView.length() == 0) { + // No text + quotedTextView.setVisibility(View.GONE); + } else { + quotedTextView.setVisibility(View.VISIBLE); + } + quoteIndicator.setColor(status.quoted_user_color); } else { quotedNameView.setVisibility(View.GONE); @@ -439,18 +439,18 @@ public class StatusViewHolder extends ViewHolder implements Constants, IStatusVi } else { text = status.text_unescaped; } - if (displayEnd == 0 || text.length() == 0) { - // No text - final SpannableString string = SpannableString.valueOf(context.getString(R.string.no_status_content_text)); - string.setSpan(new ForegroundColorSpan(ThemeUtils.getColorFromAttribute(context, - android.R.attr.textColorTertiary, textView.getCurrentTextColor())), 0, - string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - textView.setText(string); - } else if (displayEnd != -1 && displayEnd <= text.length()) { + + if (displayEnd != -1 && displayEnd <= text.length()) { textView.setText(text.subSequence(0, displayEnd)); } else { textView.setText(text); } + if (textView.length() == 0) { + // No text + textView.setVisibility(View.GONE); + } else { + textView.setVisibility(View.VISIBLE); + } if (replyCount > 0) { replyCountView.setText(UnitConvertUtils.calculateProperCount(replyCount));