Bind icon and remote views for Suggestion
Bug: 65065268 Test: robotests Change-Id: I181a9e092c56f4e45addfc1cde166fb7dac7becd
This commit is contained in:
@@ -601,6 +601,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
|
||||
public Drawable getIcon(Icon icon) {
|
||||
if (icon == null) {
|
||||
return null;
|
||||
}
|
||||
Drawable drawable = mMap.get(icon);
|
||||
if (drawable == null) {
|
||||
drawable = icon.loadDrawable(mContext);
|
||||
|
@@ -96,8 +96,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
// itemView));
|
||||
// } else
|
||||
{
|
||||
// TODO: Add icon field in Suggestion, and enable this.
|
||||
// holder.icon.setImageDrawable(mCache.getIcon(suggestion.icon));
|
||||
holder.icon.setImageDrawable(mCache.getIcon(suggestion.getIcon()));
|
||||
holder.title.setText(suggestion.getTitle());
|
||||
final CharSequence summary = suggestion.getSummary();
|
||||
if (!TextUtils.isEmpty(summary)) {
|
||||
|
@@ -17,13 +17,16 @@
|
||||
package android.service.settings.suggestions;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Parcel;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
public class Suggestion {
|
||||
private final String mId;
|
||||
private final CharSequence mTitle;
|
||||
private final CharSequence mSummary;
|
||||
private final Icon mIcon;
|
||||
private final PendingIntent mPendingIntent;
|
||||
|
||||
/**
|
||||
@@ -47,6 +50,13 @@ public class Suggestion {
|
||||
return mSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional icon for this suggestion.
|
||||
*/
|
||||
public Icon getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Intent to launch when the suggestion is activated.
|
||||
*/
|
||||
@@ -57,17 +67,11 @@ public class Suggestion {
|
||||
private Suggestion(Builder builder) {
|
||||
mTitle = builder.mTitle;
|
||||
mSummary = builder.mSummary;
|
||||
mIcon = builder.mIcon;
|
||||
mPendingIntent = builder.mPendingIntent;
|
||||
mId = builder.mId;
|
||||
}
|
||||
|
||||
private Suggestion(Parcel in) {
|
||||
mId = in.readString();
|
||||
mTitle = in.readCharSequence();
|
||||
mSummary = in.readCharSequence();
|
||||
mPendingIntent = in.readParcelable(PendingIntent.class.getClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder class for {@link Suggestion}.
|
||||
*/
|
||||
@@ -75,6 +79,7 @@ public class Suggestion {
|
||||
private final String mId;
|
||||
private CharSequence mTitle;
|
||||
private CharSequence mSummary;
|
||||
private Icon mIcon;
|
||||
private PendingIntent mPendingIntent;
|
||||
|
||||
public Builder(String id) {
|
||||
@@ -101,6 +106,14 @@ public class Suggestion {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets icon for the suggestion.
|
||||
*/
|
||||
public Builder setIcon(Icon icon) {
|
||||
mIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets suggestion intent
|
||||
*/
|
||||
|
Reference in New Issue
Block a user