Merge "Check for text type before setting text span."

This commit is contained in:
TreeHugger Robot
2017-01-04 23:31:36 +00:00
committed by Android (Google) Code Review
2 changed files with 48 additions and 4 deletions

View File

@@ -428,10 +428,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
});
}
getPreferenceScreen().removeAll();
Spannable boldSpan = (Spannable) emptyView.getText();
boldSpan.setSpan(
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
setTextSpan(emptyView.getText(), briefText);
}
@Override
@@ -461,6 +458,16 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
updateContent(mLocalAdapter.getBluetoothState());
}
@VisibleForTesting
void setTextSpan(CharSequence text, CharSequence briefText) {
if (text instanceof Spannable) {
Spannable boldSpan = (Spannable) text;
boldSpan.setSpan(
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
private final View.OnClickListener mDeviceProfilesListener = new View.OnClickListener() {
@Override
public void onClick(View v) {