Fix NPE when building suggestion identifier.

And refactored the getIdent logic into feature provider.

Change-Id: Id6f66a6942cbaf6d26ae4dca62037a6cf01179a5
Fix: 36314240
Test: make RunSettingsRoboTests
This commit is contained in:
Fan Zhang
2017-03-16 15:50:31 -07:00
parent d764c57dcc
commit 264c0c2bbe
6 changed files with 132 additions and 111 deletions

View File

@@ -190,8 +190,7 @@ public class DashboardSummary extends InstrumentedFragment
mDashboard.addItemDecoration(new DashboardDecorator(getContext()));
mDashboard.setListener(this);
Log.d(TAG, "adapter created");
mAdapter = new DashboardAdapter(getContext(), mSuggestionParser, mMetricsFeatureProvider,
bundle, mConditionManager.getConditions());
mAdapter = new DashboardAdapter(getContext(), bundle, mConditionManager.getConditions());
mDashboard.setAdapter(mAdapter);
mSuggestionDismissHandler = new SuggestionDismissController(
getContext(), mDashboard, mSuggestionParser, mAdapter);
@@ -245,8 +244,8 @@ public class DashboardSummary extends InstrumentedFragment
if (isSmartSuggestionEnabled) {
List<String> suggestionIds = new ArrayList<>(suggestions.size());
for (Tile suggestion : suggestions) {
suggestionIds.add(
DashboardAdapter.getSuggestionIdentifier(context, suggestion));
suggestionIds.add(mSuggestionFeatureProvider.getSuggestionIdentifier(
context, suggestion));
}
// TODO: create a Suggestion class to maintain the id and other info
mSuggestionFeatureProvider.rankSuggestions(suggestions, suggestionIds);