public static final class ContentRecommendation.Builder extends Object
ContentRecommendation
objects. Provides a convenient way to set the
various fields of a ContentRecommendation
.
Example:
ContentRecommendation rec = new ContentRecommendation.Builder() .setIdInfo(id, "MyTagId") .setTitle("My Content Recommendation") .setText("An example of content recommendation") .setContentImage(myBitmap) .setBadgeIcon(R.drawable.app_icon) .setGroup("Trending") .build();
Constructor and Description |
---|
Builder()
Constructs a new Builder.
|
Modifier and Type | Method and Description |
---|---|
ContentRecommendation |
build()
Combine all of the options that have been set and return a new
ContentRecommendation object. |
ContentRecommendation.Builder |
setAutoDismiss(boolean autoDismiss)
Sets the flag indicating if the recommendation should be dismissed automatically.
|
ContentRecommendation.Builder |
setBackgroundImageUri(String imageUri)
Sets the Content URI that will be used to retrieve the background image for the
recommendation.
|
ContentRecommendation.Builder |
setBadgeIcon(int iconResourceId)
Sets the resource ID for the recommendation badging icon.
|
ContentRecommendation.Builder |
setColor(int color)
Sets the accent color value to be used in the UI when displaying this content
recommendation to the user.
|
ContentRecommendation.Builder |
setContentImage(Bitmap image)
Sets the recommendation image.
|
ContentRecommendation.Builder |
setContentIntentData(int intentType,
Intent intent,
int requestCode,
Bundle options)
Sets the data for the Intent that will be issued when the user clicks on the
recommendation.
|
ContentRecommendation.Builder |
setContentTypes(String[] types)
Sets the content types associated with the content recommendation.
|
ContentRecommendation.Builder |
setDismissIntentData(int intentType,
Intent intent,
int requestCode,
Bundle options)
Sets the data for the Intent that will be issued when the recommendation gets dismissed
from the Home Screen, due to an user action.
|
ContentRecommendation.Builder |
setGenres(String[] genres)
Sets the content genres for the recommendation.
|
ContentRecommendation.Builder |
setGroup(String groupTag)
Sets the String group ID tag for the recommendation.
|
ContentRecommendation.Builder |
setIdTag(String idTag)
Sets the Id tag that uniquely identifies this recommendation object.
|
ContentRecommendation.Builder |
setMaturityRating(String maturityRating)
Sets the maturity level rating for the content.
|
ContentRecommendation.Builder |
setPricingInformation(String priceType,
String priceValue)
Sets the pricing and availability information for the recommendation.
|
ContentRecommendation.Builder |
setProgress(int max,
int progress)
Sets the progress information for the content pointed to by the recommendation.
|
ContentRecommendation.Builder |
setRunningTime(long length)
Sets the running time (when applicable) for the content.
|
ContentRecommendation.Builder |
setSortKey(String sortKey)
Sets the String sort key for the recommendation.
|
ContentRecommendation.Builder |
setSourceName(String source)
Sets the source application name for the recommendation.
|
ContentRecommendation.Builder |
setStatus(int contentStatus)
Sets the availability status for the content.
|
ContentRecommendation.Builder |
setText(String description)
Sets the description text for the recommendation.
|
ContentRecommendation.Builder |
setTitle(String title)
Sets the content title for the recommendation.
|
public ContentRecommendation.Builder setIdTag(String idTag)
idTag
- A String tag identifier for this recommendation.public ContentRecommendation.Builder setTitle(String title)
title
- A String containing the recommendation content title.public ContentRecommendation.Builder setText(@Nullable String description)
description
- A String containing the recommendation description text.public ContentRecommendation.Builder setSourceName(@Nullable String source)
If the source name is never set, or set to null, the application name retrieved from its package will be used by default.
source
- A String containing the recommendation source name.public ContentRecommendation.Builder setContentImage(Bitmap image)
image
- A Bitmap containing the recommendation image.public ContentRecommendation.Builder setBadgeIcon(@DrawableRes int iconResourceId)
The resource id represents the icon resource in the source application package. If not set, or an invalid resource ID is specified, the application icon retrieved from its package will be used by default.
iconResourceId
- An integer id for the badge icon resource.public ContentRecommendation.Builder setBackgroundImageUri(@Nullable String imageUri)
imageUri
- A Content URI pointing to the recommendation background image.public ContentRecommendation.Builder setColor(int color)
color
- An integer value representing the accent color for this recommendation.public ContentRecommendation.Builder setGroup(@Nullable String groupTag)
Recommendations in the same group are ranked by the Home Screen together, and the sort order within a group is respected. This can be useful if the application has different sources for recommendations, like "trending", "subscriptions", and "new music" categories for YouTube, where the user can be more interested in recommendations from one group than another.
groupTag
- A String containing the group ID tag for this recommendation.public ContentRecommendation.Builder setSortKey(@Nullable String sortKey)
The sort key must be a String representation of a float number between 0.0 and 1.0, and is used to indicate the relative importance (and sort order) of a single recommendation within its specified group. The recommendations will be ordered in decreasing order of importance within a given group.
sortKey
- A String containing the sort key for this recommendation.public ContentRecommendation.Builder setProgress(int max, int progress)
max
- The maximum value for the progress of this content.progress
- The progress amount for this content. Must be in the range (0 - max).public ContentRecommendation.Builder setAutoDismiss(boolean autoDismiss)
Auto-dismiss notifications are automatically removed from the Home Screen when the user clicks on them.
autoDismiss
- A boolean indicating if the recommendation should be auto dismissed or
not.public ContentRecommendation.Builder setContentIntentData(int intentType, Intent intent, int requestCode, @Nullable Bundle options)
The Intent data fields provided correspond to the fields passed into the
PendingIntent
factory methods, when creating a new PendingIntent. The actual
PengindIntent object will only be created at the time a recommendation is posted to the
Home Screen.
intentType
- The type of PendingIntent
to be created when posting this
recommendation.intent
- The Intent which to be issued when the recommendation is clicked on.requestCode
- The private request code to be used when creating the
PendingIntent
options
- Only used for the Activity Intent type. Additional options for how the
Activity should be started. May be null if there are no options.public ContentRecommendation.Builder setDismissIntentData(int intentType, @Nullable Intent intent, int requestCode, @Nullable Bundle options)
The Intent data fields provided correspond to the fields passed into the
PendingIntent
factory methods, when creating a new PendingIntent. The actual
PengindIntent object will only be created at the time a recommendation is posted to the
Home Screen.
intentType
- The type of PendingIntent
to be created when posting this
recommendation.intent
- The Intent which gets issued when the recommendation is dismissed from the
Home Screen.requestCode
- The private request code to be used when creating the
PendingIntent
options
- Only used for the Activity Intent type. Additional options for how the
Activity should be started. May be null if there are no options.public ContentRecommendation.Builder setContentTypes(String[] types)
types
- Array of predefined type tags (see the CONTENT_TYPE_*
constants) that describe the recommended content.public ContentRecommendation.Builder setGenres(String[] genres)
Some examples: "comedy", "action", "dance", "electronica", "racing", etc.
genres
- Array of genre string tags that describe the recommended content.public ContentRecommendation.Builder setPricingInformation(String priceType, @Nullable String priceValue)
priceType
- Pricing type for this content. Must be one of the predefined pricing
type tags (see the CONTENT_PRICING_*
constants).priceValue
- A string containing a representation of the content price in the
current locale and currency.public ContentRecommendation.Builder setStatus(int contentStatus)
contentStatus
- The status value for this content. Must be one of the predefined
content status values (see the CONTENT_STATUS_*
constants).public ContentRecommendation.Builder setMaturityRating(String maturityRating)
maturityRating
- A tag indicating the maturity level rating for the content. This
tag must be one of the predefined maturity rating tags (see the
CONTENT_MATURITY_*
constants).public ContentRecommendation.Builder setRunningTime(long length)
length
- The running time, in seconds, of the content.public ContentRecommendation build()
ContentRecommendation
object.