measure text manually
hopefully fix sk22#422
This commit is contained in:
parent
d5b6c02b22
commit
6fef51fcbb
@ -503,7 +503,6 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
holder.getItem().status.textExpandable = expandable;
|
||||
HeaderStatusDisplayItem.Holder header = findHolderOfType(holder.getItemID(), HeaderStatusDisplayItem.Holder.class);
|
||||
if (header != null) header.rebind();
|
||||
holder.rebind();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,11 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
||||
|
||||
private final float textMaxHeight, textCollapsedHeight;
|
||||
private final LinearLayout.LayoutParams collapseParams, wrapParams;
|
||||
private final ViewGroup parent;
|
||||
|
||||
public Holder(Activity activity, ViewGroup parent){
|
||||
super(activity, R.layout.display_item_text, parent);
|
||||
this.parent=parent;
|
||||
text=findViewById(R.id.text);
|
||||
spoilerTitle=findViewById(R.id.spoiler_title);
|
||||
spoilerTitleInline=findViewById(R.id.spoiler_title_inline);
|
||||
@ -228,19 +230,16 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
||||
readMore.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (GlobalUserPreferences.collapseLongPosts) {
|
||||
text.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
text.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
boolean tooBig = text.getMeasuredHeight() > textMaxHeight;
|
||||
boolean inTimeline = !item.textSelectable;
|
||||
boolean hasSpoiler = !TextUtils.isEmpty(item.status.spoilerText);
|
||||
boolean expandable = inTimeline && tooBig && !hasSpoiler;
|
||||
item.parentFragment.onEnableExpandable(Holder.this, expandable);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
text.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
||||
|
||||
if (GlobalUserPreferences.collapseLongPosts && !item.status.textExpandable) {
|
||||
boolean tooBig = text.getMeasuredHeight() > textMaxHeight;
|
||||
boolean inTimeline = !item.textSelectable;
|
||||
boolean hasSpoiler = !TextUtils.isEmpty(item.status.spoilerText);
|
||||
boolean expandable = inTimeline && tooBig && !hasSpoiler;
|
||||
item.parentFragment.onEnableExpandable(Holder.this, expandable);
|
||||
}
|
||||
|
||||
readMore.setVisibility(item.status.textExpandable && !item.status.textExpanded ? View.VISIBLE : View.GONE);
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="text_max_height">350dp</dimen>
|
||||
<dimen name="text_max_height">220dp</dimen>
|
||||
<dimen name="text_collapsed_height">150dp</dimen>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user