kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix infinite post loop when parent is GONE.
rodzic
bf2ab74ca4
commit
5a51544cae
|
@ -23,6 +23,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.view.ViewKt;
|
||||||
import androidx.core.widget.TextViewCompat;
|
import androidx.core.widget.TextViewCompat;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
@ -35,6 +36,8 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
|
||||||
|
|
||||||
public class EmojiTextView extends AppCompatTextView {
|
public class EmojiTextView extends AppCompatTextView {
|
||||||
|
|
||||||
|
@ -269,12 +272,7 @@ public class EmojiTextView extends AppCompatTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ellipsizeEmojiTextForMaxLines() {
|
private void ellipsizeEmojiTextForMaxLines() {
|
||||||
post(() -> {
|
Runnable ellipsize = () -> {
|
||||||
if (getLayout() == null) {
|
|
||||||
ellipsizeEmojiTextForMaxLines();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxLines = TextViewCompat.getMaxLines(EmojiTextView.this);
|
int maxLines = TextViewCompat.getMaxLines(EmojiTextView.this);
|
||||||
if (maxLines <= 0 && maxLength < 0) {
|
if (maxLines <= 0 && maxLength < 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -297,8 +295,17 @@ public class EmojiTextView extends AppCompatTextView {
|
||||||
|
|
||||||
super.setText(emojified, BufferType.SPANNABLE);
|
super.setText(emojified, BufferType.SPANNABLE);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (getLayout() != null) {
|
||||||
|
ellipsize.run();
|
||||||
|
} else {
|
||||||
|
ViewKt.doOnNextLayout(this, view -> {
|
||||||
|
ellipsize.run();
|
||||||
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean unchanged(CharSequence text, CharSequence overflowText, BufferType bufferType) {
|
private boolean unchanged(CharSequence text, CharSequence overflowText, BufferType bufferType) {
|
||||||
return Util.equals(previousText, text) &&
|
return Util.equals(previousText, text) &&
|
||||||
|
|
Ładowanie…
Reference in New Issue