Fixed a bug where the notification texts wouldn\'t animate
am: 049f6adfb8
* commit '049f6adfb8fea4622af5cd3247514ec7a461bf46':
Fixed a bug where the notification texts wouldn't animate
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification;
|
package com.android.systemui.statusbar.notification;
|
||||||
|
|
||||||
|
import android.text.Layout;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Pools;
|
import android.util.Pools;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -28,14 +29,13 @@ public class TextViewTransformState extends TransformState {
|
|||||||
|
|
||||||
private static Pools.SimplePool<TextViewTransformState> sInstancePool
|
private static Pools.SimplePool<TextViewTransformState> sInstancePool
|
||||||
= new Pools.SimplePool<>(40);
|
= new Pools.SimplePool<>(40);
|
||||||
private CharSequence mText;
|
private TextView mText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initFrom(View view) {
|
public void initFrom(View view) {
|
||||||
super.initFrom(view);
|
super.initFrom(view);
|
||||||
if (view instanceof TextView) {
|
if (view instanceof TextView) {
|
||||||
TextView txt = (TextView) view;
|
mText = (TextView) view;
|
||||||
mText = txt.getText();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +43,27 @@ public class TextViewTransformState extends TransformState {
|
|||||||
protected boolean sameAs(TransformState otherState) {
|
protected boolean sameAs(TransformState otherState) {
|
||||||
if (otherState instanceof TextViewTransformState) {
|
if (otherState instanceof TextViewTransformState) {
|
||||||
TextViewTransformState otherTvs = (TextViewTransformState) otherState;
|
TextViewTransformState otherTvs = (TextViewTransformState) otherState;
|
||||||
return TextUtils.equals(otherTvs.mText, mText);
|
if(TextUtils.equals(otherTvs.mText.getText(), mText.getText())) {
|
||||||
|
int ownEllipsized = getEllipsisCount();
|
||||||
|
int otherEllipsized = otherTvs.getEllipsisCount();
|
||||||
|
return ownEllipsized == otherEllipsized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.sameAs(otherState);
|
return super.sameAs(otherState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getEllipsisCount() {
|
||||||
|
Layout l = mText.getLayout();
|
||||||
|
if (l != null) {
|
||||||
|
int lines = l.getLineCount();
|
||||||
|
if (lines > 0) {
|
||||||
|
// we only care about the first line
|
||||||
|
return l.getEllipsisCount(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static TextViewTransformState obtain() {
|
public static TextViewTransformState obtain() {
|
||||||
TextViewTransformState instance = sInstancePool.acquire();
|
TextViewTransformState instance = sInstancePool.acquire();
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user