Merge "Call SuggestionService.launch when click suggestion."
This commit is contained in:
committed by
Android (Google) Code Review
commit
b40d1db1ae
@@ -430,16 +430,16 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
if (position == SUGGESTION_CONDITION_HEADER_POSITION) {
|
||||
if (suggestions != null && suggestions.size() > 0) {
|
||||
conditionOnly = false;
|
||||
mSuggestionAdapter = new SuggestionAdapter(mContext, (List<Tile>)
|
||||
mDashboardData.getItemEntityByPosition(position),
|
||||
mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
|
||||
(List<Tile>) mDashboardData.getItemEntityByPosition(position),
|
||||
null, mSuggestionsShownLogged);
|
||||
mSuggestionDismissHandler = new SuggestionDismissController(mContext,
|
||||
holder.data, mSuggestionControllerMixin, mSuggestionParser, mCallback);
|
||||
holder.data.setAdapter(mSuggestionAdapter);
|
||||
} else if (suggestionsV2 != null && suggestionsV2.size() > 0) {
|
||||
conditionOnly = false;
|
||||
mSuggestionAdapter = new SuggestionAdapter(mContext, null,
|
||||
(List<Suggestion>) mDashboardData.getItemEntityByPosition(position),
|
||||
mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
|
||||
null, (List<Suggestion>) mDashboardData.getItemEntityByPosition(position),
|
||||
mSuggestionsShownLogged);
|
||||
mSuggestionDismissHandler = new SuggestionDismissController(mContext,
|
||||
holder.data, mSuggestionControllerMixin, null /* parser */, mCallback);
|
||||
|
@@ -48,11 +48,13 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
private final List<Suggestion> mSuggestionsV2;
|
||||
private final IconCache mCache;
|
||||
private final List<String> mSuggestionsShownLogged;
|
||||
private final SuggestionControllerMixin mSuggestionControllerMixin;
|
||||
|
||||
public SuggestionAdapter(Context context, List<Tile> suggestions,
|
||||
List<Suggestion> suggestionsV2,
|
||||
public SuggestionAdapter(Context context, SuggestionControllerMixin suggestionControllerMixin,
|
||||
List<Tile> suggestions, List<Suggestion> suggestionsV2,
|
||||
List<String> suggestionsShownLogged) {
|
||||
mContext = context;
|
||||
mSuggestionControllerMixin = suggestionControllerMixin;
|
||||
mSuggestions = suggestions;
|
||||
mSuggestionsV2 = suggestionsV2;
|
||||
mSuggestionsShownLogged = suggestionsShownLogged;
|
||||
@@ -112,6 +114,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_SUGGESTION, id);
|
||||
try {
|
||||
suggestion.getPendingIntent().send();
|
||||
mSuggestionControllerMixin.launchSuggestion(suggestion);
|
||||
} catch (PendingIntent.CanceledException e) {
|
||||
Log.w(TAG, "Failed to start suggestion " + suggestion.getTitle());
|
||||
}
|
||||
|
@@ -122,6 +122,19 @@ public class SuggestionController {
|
||||
}
|
||||
}
|
||||
|
||||
public void launchSuggestion(Suggestion suggestion) {
|
||||
if (!isReady()) {
|
||||
Log.w(TAG, "SuggestionController not ready, cannot launch " + suggestion.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mRemoteService.launchSuggestion(suggestion);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Error when calling launchSuggestion()", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the manager is ready
|
||||
*/
|
||||
|
@@ -115,4 +115,8 @@ public class SuggestionControllerMixin implements SuggestionController.ServiceCo
|
||||
public void dismissSuggestion(Suggestion suggestion) {
|
||||
mSuggestionController.dismissSuggestions(suggestion);
|
||||
}
|
||||
|
||||
public void launchSuggestion(Suggestion suggestion) {
|
||||
mSuggestionController.launchSuggestion(suggestion);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user