Use getSummary() to get tile summary text.

Bug: 77600770
Test: robotests
Change-Id: Iecef09853bb49bc259502494912ed81d52e2d7ce
This commit is contained in:
Fan Zhang
2018-08-20 14:13:14 -07:00
parent 54cfb64987
commit 64951163b8
7 changed files with 37 additions and 34 deletions

View File

@@ -172,8 +172,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
}
private void bindSummary(Preference preference, Tile tile) {
if (tile.summary != null) {
preference.setSummary(tile.summary);
final CharSequence summary = tile.getSummary(mContext);
if (summary != null) {
preference.setSummary(summary);
} else if (tile.getMetaData() != null
&& tile.getMetaData().containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
// Set a placeholder summary before starting to fetch real summary, this is necessary
@@ -183,9 +184,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
ThreadUtils.postOnBackgroundThread(() -> {
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
final String uri = tile.getMetaData().getString(META_DATA_PREFERENCE_SUMMARY_URI);
final String summary = TileUtils.getTextFromUri(
final String summaryFromUri = TileUtils.getTextFromUri(
mContext, uri, providerMap, META_DATA_PREFERENCE_SUMMARY);
ThreadUtils.postOnMainThread(() -> preference.setSummary(summary));
ThreadUtils.postOnMainThread(() -> preference.setSummary(summaryFromUri));
});
} else {
preference.setSummary(R.string.summary_placeholder);