Merge "Disabling unnecessary requestLayout calls in BubbleTextView" into ub-launcher3-master
This commit is contained in:
commit
76d557446d
|
@ -31,7 +31,6 @@
|
||||||
android:layout_height="@dimen/widget_section_height"
|
android:layout_height="@dimen/widget_section_height"
|
||||||
android:background="?android:attr/colorPrimary"
|
android:background="?android:attr/colorPrimary"
|
||||||
android:drawablePadding="@dimen/widget_section_horizontal_padding"
|
android:drawablePadding="@dimen/widget_section_horizontal_padding"
|
||||||
android:ellipsize="end"
|
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:paddingBottom="@dimen/widget_section_vertical_padding"
|
android:paddingBottom="@dimen/widget_section_vertical_padding"
|
||||||
|
|
|
@ -112,7 +112,6 @@
|
||||||
<item name="android:focusable">true</item>
|
<item name="android:focusable">true</item>
|
||||||
<item name="android:gravity">center_horizontal</item>
|
<item name="android:gravity">center_horizontal</item>
|
||||||
<item name="android:singleLine">true</item>
|
<item name="android:singleLine">true</item>
|
||||||
<item name="android:ellipsize">marquee</item>
|
|
||||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||||
<item name="android:fontFamily">sans-serif-condensed</item>
|
<item name="android:fontFamily">sans-serif-condensed</item>
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.graphics.Rect;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.graphics.ColorUtils;
|
import android.support.v4.graphics.ColorUtils;
|
||||||
|
import android.text.TextUtils.TruncateAt;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
@ -163,10 +164,18 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
mLongPressHelper = new CheckLongPressHelper(this);
|
mLongPressHelper = new CheckLongPressHelper(this);
|
||||||
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
|
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
|
||||||
|
|
||||||
|
setEllipsize(TruncateAt.END);
|
||||||
setAccessibilityDelegate(mActivity.getAccessibilityDelegate());
|
setAccessibilityDelegate(mActivity.getAccessibilityDelegate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
||||||
|
// Disable marques when not focused to that, so that updating text does not cause relayout.
|
||||||
|
setEllipsize(focused ? TruncateAt.MARQUEE : TruncateAt.END);
|
||||||
|
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the view so it can be recycled.
|
* Resets the view so it can be recycled.
|
||||||
*/
|
*/
|
||||||
|
@ -521,31 +530,30 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||||
* Sets the icon for this view based on the layout direction.
|
* Sets the icon for this view based on the layout direction.
|
||||||
*/
|
*/
|
||||||
private void setIcon(Drawable icon) {
|
private void setIcon(Drawable icon) {
|
||||||
mIcon = icon;
|
|
||||||
mIcon.setBounds(0, 0, mIconSize, mIconSize);
|
|
||||||
if (mIsIconVisible) {
|
if (mIsIconVisible) {
|
||||||
applyCompoundDrawables(mIcon);
|
applyCompoundDrawables(icon);
|
||||||
}
|
}
|
||||||
|
mIcon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconVisible(boolean visible) {
|
public void setIconVisible(boolean visible) {
|
||||||
mIsIconVisible = visible;
|
mIsIconVisible = visible;
|
||||||
mDisableRelayout = true;
|
Drawable icon = visible ? mIcon : new ColorDrawable(Color.TRANSPARENT);
|
||||||
Drawable icon = mIcon;
|
|
||||||
if (!visible) {
|
|
||||||
icon = new ColorDrawable(Color.TRANSPARENT);
|
|
||||||
icon.setBounds(0, 0, mIconSize, mIconSize);
|
|
||||||
}
|
|
||||||
applyCompoundDrawables(icon);
|
applyCompoundDrawables(icon);
|
||||||
mDisableRelayout = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyCompoundDrawables(Drawable icon) {
|
protected void applyCompoundDrawables(Drawable icon) {
|
||||||
|
// If we had already set an icon before, disable relayout as the icon size is the
|
||||||
|
// same as before.
|
||||||
|
mDisableRelayout = mIcon != null;
|
||||||
|
|
||||||
|
icon.setBounds(0, 0, mIconSize, mIconSize);
|
||||||
if (mLayoutHorizontal) {
|
if (mLayoutHorizontal) {
|
||||||
setCompoundDrawablesRelative(icon, null, null, null);
|
setCompoundDrawablesRelative(icon, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
setCompoundDrawables(null, icon, null, null);
|
setCompoundDrawables(null, icon, null, null);
|
||||||
}
|
}
|
||||||
|
mDisableRelayout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Region;
|
|
||||||
import android.support.v4.graphics.ColorUtils;
|
import android.support.v4.graphics.ColorUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
Loading…
Reference in New Issue