19f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima/*
2ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikas * Copyright 2018 The Android Open Source Project
39f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima *
49f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * Licensed under the Apache License, Version 2.0 (the "License");
59f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * you may not use this file except in compliance with the License.
69f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * You may obtain a copy of the License at
79f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima *
89f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima *      http://www.apache.org/licenses/LICENSE-2.0
99f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima *
109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * Unless required by applicable law or agreed to in writing, software
119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * distributed under the License is distributed on an "AS IS" BASIS,
129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * See the License for the specific language governing permissions and
149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * limitations under the License.
159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima */
169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
17ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikaspackage androidx.recommendation.app;
189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.app.Notification;
209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.app.PendingIntent;
219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.content.Context;
229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.content.Intent;
239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.graphics.Bitmap;
249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport android.os.Bundle;
251cabbc50ec35fd735a8171c9a8f46a1297fe805bAurimas Liutikasimport android.text.TextUtils;
261cabbc50ec35fd735a8171c9a8f46a1297fe805bAurimas Liutikas
27ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.ColorInt;
28ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.DrawableRes;
29ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.IntDef;
30ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.Nullable;
31ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.StringDef;
329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
335ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikasimport java.lang.annotation.Retention;
345ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikasimport java.lang.annotation.RetentionPolicy;
359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limaimport java.util.Arrays;
369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima/**
389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * The ContentRecommendation object encapsulates all application provided data for a single content
399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima * recommendation item.
409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima */
419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Limapublic final class ContentRecommendation
429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima{
439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @StringDef({
449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_VIDEO,
459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_MOVIE,
469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_TRAILER,
479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_SERIAL,
489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_MUSIC,
499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_RADIO,
509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_PODCAST,
519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_NEWS,
529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_SPORTS,
539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_APP,
549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_GAME,
559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_BOOK,
569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_COMIC,
579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_MAGAZINE,
589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_TYPE_WEBSITE,
599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    })
605ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikas    @Retention(RetentionPolicy.SOURCE)
619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public @interface ContentType {}
629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a video clip.
669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_VIDEO = "android.contentType.video";
689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a movie.
729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_MOVIE = "android.contentType.movie";
749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a trailer.
789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_TRAILER = "android.contentType.trailer";
809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is serial. It can refer to an entire show, a single season or
849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * series, or a single episode.
859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_SERIAL = "android.contentType.serial";
879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a song or album.
919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_MUSIC = "android.contentType.music";
939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a radio station.
979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_RADIO = "android.contentType.radio";
999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a podcast.
1039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_PODCAST = "android.contentType.podcast";
1059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a news item.
1099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_NEWS = "android.contentType.news";
1119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is sports.
1159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_SPORTS = "android.contentType.sports";
1179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is an application.
1219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_APP = "android.contentType.app";
1239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a game.
1279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_GAME = "android.contentType.game";
1299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a book.
1339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_BOOK = "android.contentType.book";
1359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a comic book.
1399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_COMIC = "android.contentType.comic";
1419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a magazine.
1459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_MAGAZINE = "android.contentType.magazine";
1479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentTypes} to indicate that the content referred
1509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification item is a website.
1519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_TYPE_WEBSITE = "android.contentType.website";
1539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @StringDef({
1559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_PRICING_FREE,
1569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_PRICING_RENTAL,
1579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_PRICING_PURCHASE,
1589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_PRICING_PREORDER,
1599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_PRICING_SUBSCRIPTION,
1609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    })
1615ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikas    @Retention(RetentionPolicy.SOURCE)
1629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public @interface ContentPricing {}
1639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setPricingInformation} to indicate that the content
1669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * referred by the notification item is free to consume.
1679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_PRICING_FREE = "android.contentPrice.free";
1699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setPricingInformation} to indicate that the content
1729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * referred by the notification item is available as a rental, and the price value provided is
1739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * the rental price for the item.
1749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_PRICING_RENTAL = "android.contentPrice.rental";
1769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setPricingInformation} to indicate that the content
1799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * referred by the notification item is available for purchase, and the price value provided is
1809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * the purchase price for the item.
1819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_PRICING_PURCHASE = "android.contentPrice.purchase";
1839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setPricingInformation} to indicate that the content
1869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * referred by the notification item is available currently as a pre-order, and the price value
1879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * provided is the purchase price for the item.
1889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_PRICING_PREORDER = "android.contentPrice.preorder";
1909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
1929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setPricingInformation} to indicate that the content
1939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * referred by the notification item is available as part of a subscription based service, and
1949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * the price value provided is the subscription price for the service.
1959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
1969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_PRICING_SUBSCRIPTION =
1979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            "android.contentPrice.subscription";
1989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
1999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @IntDef({
2009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_STATUS_READY,
2019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_STATUS_PENDING,
2029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_STATUS_AVAILABLE,
2039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_STATUS_UNAVAILABLE,
2049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    })
2055ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikas    @Retention(RetentionPolicy.SOURCE)
2069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public @interface ContentStatus {}
2079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setStatus} to indicate that the content referred by the
2109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * notification is available and ready to be consumed immediately.
2119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int CONTENT_STATUS_READY = 0;
2139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setStatus} to indicate that the content referred by the
2169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * notification is pending, waiting on either a download or purchase operation to complete
2179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * before it can be consumed.
2189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int CONTENT_STATUS_PENDING = 1;
2209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setStatus} to indicate that the content referred by the
2239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * notification is available, but needs to be first purchased, rented, subscribed or downloaded
2249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * before it can be consumed.
2259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int CONTENT_STATUS_AVAILABLE = 2;
2279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setStatus} to indicate that the content referred by the
2309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * notification is not available. This could be content not available in a certain region or
2319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * incompatible with the device in use.
2329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int CONTENT_STATUS_UNAVAILABLE = 3;
2349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @StringDef({
2369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_MATURITY_ALL,
2379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_MATURITY_LOW,
2389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_MATURITY_MEDIUM,
2399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        CONTENT_MATURITY_HIGH,
2409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    })
2415ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikas    @Retention(RetentionPolicy.SOURCE)
2429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public @interface ContentMaturity {}
2439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setMaturityRating} to indicate that the content referred
2469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification is suitable for all audiences.
2479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_MATURITY_ALL = "android.contentMaturity.all";
2499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setMaturityRating} to indicate that the content referred
2529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification is suitable for audiences of low maturity and above.
2539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_MATURITY_LOW = "android.contentMaturity.low";
2559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setMaturityRating} to indicate that the content referred
2589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification is suitable for audiences of medium maturity and above.
2599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_MATURITY_MEDIUM = "android.contentMaturity.medium";
2619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setMaturityRating} to indicate that the content referred
2649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * by the notification is suitable for audiences of high maturity and above.
2659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final String CONTENT_MATURITY_HIGH = "android.contentMaturity.high";
2679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @IntDef({
2699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            INTENT_TYPE_ACTIVITY,
2709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            INTENT_TYPE_BROADCAST,
2719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            INTENT_TYPE_SERVICE,
2729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    })
2735ae0cd07b36686fb626cfbb94965b398cf4e7cbeAurimas Liutikas    @Retention(RetentionPolicy.SOURCE)
2749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public @interface IntentType {
2759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
2769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentIntentData} and
2799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * {@link Builder#setDismissIntentData} to indicate that a {@link PendingIntent} for an Activity
2809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * should be created when posting the recommendation to the HomeScreen.
2819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int INTENT_TYPE_ACTIVITY = 1;
2839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentIntentData} and
2869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * {@link Builder#setDismissIntentData} to indicate that a {@link PendingIntent} for a Broadcast
2879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * should be created when posting the recommendation to the HomeScreen.
2889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int INTENT_TYPE_BROADCAST = 2;
2909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Value to be used with {@link Builder#setContentIntentData} and
2939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * {@link Builder#setDismissIntentData} to indicate that a {@link PendingIntent} for a Service
2949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * should be created when posting the recommendation to the HomeScreen.
2959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
2969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final int INTENT_TYPE_SERVICE = 3;
2979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
2989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
2999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Object used to encapsulate the data to be used to build the {@link PendingIntent} object
3009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * associated with a given content recommendation, at the time this recommendation gets posted
3019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * to the home Screen.
3029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
3039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * The members of this object correspond to the fields passed into the {@link PendingIntent}
3049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * factory methods, when creating a new PendingIntent.
3059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
3069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static class IntentData {
3079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        int mType;
3089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        Intent mIntent;
3099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        int mRequestCode;
3109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        Bundle mOptions;
3119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mIdTag;
3149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mTitle;
3159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mText;
3169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mSourceName;
3179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final Bitmap mContentImage;
3189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final int mBadgeIconId;
3199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mBackgroundImageUri;
3209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final int mColor;
3219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final IntentData mContentIntentData;
3229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final IntentData mDismissIntentData;
3239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String[] mContentTypes;
3249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String[] mContentGenres;
3259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mPriceType;
3269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mPriceValue;
3279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final String mMaturityRating;
3289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private final long mRunningTime;
3299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    // Mutable fields
3319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private String mGroup;
3329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private String mSortKey;
3339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private int mProgressAmount;
3349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private int mProgressMax;
3359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private boolean mAutoDismiss;
3369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private int mStatus;
3379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private ContentRecommendation(Builder builder) {
3399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mIdTag = builder.mBuilderIdTag;
3409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mTitle = builder.mBuilderTitle;
3419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mText = builder.mBuilderText;
3429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mSourceName = builder.mBuilderSourceName;
3439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mContentImage = builder.mBuilderContentImage;
3449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mBadgeIconId = builder.mBuilderBadgeIconId;
3459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mBackgroundImageUri = builder.mBuilderBackgroundImageUri;
3469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mColor = builder.mBuilderColor;
3479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mContentIntentData = builder.mBuilderContentIntentData;
3489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mDismissIntentData = builder.mBuilderDismissIntentData;
3499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mContentTypes = builder.mBuilderContentTypes;
3509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mContentGenres = builder.mBuilderContentGenres;
3519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mPriceType = builder.mBuilderPriceType;
3529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mPriceValue = builder.mBuilderPriceValue;
3539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mMaturityRating = builder.mBuilderMaturityRating;
3549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mRunningTime = builder.mBuilderRunningTime;
3559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mGroup = builder.mBuilderGroup;
3579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mSortKey = builder.mBuilderSortKey;
3589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mProgressAmount = builder.mBuilderProgressAmount;
3599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mProgressMax = builder.mBuilderProgressMax;
3609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mAutoDismiss = builder.mBuilderAutoDismiss;
3619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mStatus = builder.mBuilderStatus;
3629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
3659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the String Id tag which uniquely identifies this recommendation.
3669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
3679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return The String Id tag for this recommendation.
3689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
3699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getIdTag() {
3709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mIdTag;
3719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
3749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the content title for this recommendation.
3759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
3769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A String containing the recommendation content title.
3779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
3789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getTitle() {
3799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mTitle;
3809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
3839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the description text for this recommendation.
3849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
3859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A String containing the recommendation description text.
3869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
3879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getText() {
3889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mText;
3899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
3919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
3929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the source application name for this recommendation.
3939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
3949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A String containing the recommendation source name.
3959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
3969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getSourceName() {
3979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mSourceName;
3989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
3999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the Bitmap containing the recommendation image.
4029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A Bitmap containing the recommendation image.
4049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public Bitmap getContentImage() {
4069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mContentImage;
4079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the resource id for the recommendation badging icon.
4119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
4129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * The resource id represents the icon resource in the source application package.
4139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An integer id for the badge icon resource.
4159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int getBadgeImageResourceId() {
4179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mBadgeIconId;
4189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns a Content URI that can be used to retrieve the background image for this
4229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendation.
4239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A Content URI pointing to the recommendation background image.
4259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getBackgroundImageUri() {
4279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mBackgroundImageUri;
4289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the accent color value to be used in the UI when displaying this content
4329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendation to the user.
4339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An integer value representing the accent color for this recommendation.
4359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int getColor() {
4379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mColor;
4389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Sets the String group ID tag for this recommendation.
4429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
4439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Recommendations in the same group are ranked by the Home Screen together, and the sort order
4449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * within a group is respected. This can be useful if the application has different sources for
4459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendations, like "trending", "subscriptions", and "new music" categories for YouTube,
4469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * where the user can be more interested in recommendations from one group than another.
4479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param groupTag A String containing the group ID tag for this recommendation.
4499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public void setGroup(String groupTag) {
4519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mGroup = groupTag;
4529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the String group ID tag for this recommendation.
4569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A String containing the group ID tag for this recommendation.
4589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getGroup() {
4609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mGroup;
4619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Sets the String sort key for this recommendation.
4659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
4669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * The sort key must be a String representation of a float number between 0.0 and 1.0, and is
4679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * used to indicate the relative importance (and sort order) of a single recommendation within
4689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * its specified group. The recommendations will be ordered in decreasing order of importance
4699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * within a given group.
4709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param sortKey A String containing the sort key for this recommendation.
4729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public void setSortKey(String sortKey) {
4749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mSortKey = sortKey;
4759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the String sort key for this recommendation.
4799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A String containing the sort key for this recommendation.
4819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getSortKey() {
4839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mSortKey;
4849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
4869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
4879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Sets the progress information for the content pointed to by this recommendation.
4889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
4899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param max The maximum value for the progress of this content.
4909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param progress The progress amount for this content. Must be in the range (0 - max).
4919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
4929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public void setProgress(int max, int progress) {
4939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (max < 0 || progress < 0) {
4949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            throw new IllegalArgumentException();
4959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
4969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mProgressMax = max;
4979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mProgressAmount = progress;
4989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
4999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Indicates if this recommendation contains valid progress information.
5029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return true if the recommendation contains valid progress data, false otherwise.
5049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public boolean hasProgressInfo() {
5069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mProgressMax != 0;
5079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the maximum value for the progress data of this recommendation.
5119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An integer representing the maximum progress value.
5139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int getProgressMax() {
5159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mProgressMax;
5169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the progress amount for this recommendation.
5209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An integer representing the recommendation progress amount.
5229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int getProgressValue() {
5249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mProgressAmount;
5259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Sets the flag indicating if this recommendation should be dismissed automatically.
5299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
5309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Auto-dismiss notifications are automatically removed from the Home Screen when the user
5319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * clicks on them.
5329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param autoDismiss A boolean indicating if the recommendation should be auto dismissed or
5349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *            not.
5359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public void setAutoDismiss(boolean autoDismiss) {
5379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mAutoDismiss = autoDismiss;
5389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Indicates whether this recommendation should be dismissed automatically.
5429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
5439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Auto-dismiss notifications are automatically removed from the Home Screen when the user
5449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * clicks on them.
5459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return true if the recommendation is marked for auto dismissal, or false otherwise.
5479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public boolean isAutoDismiss() {
5499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mAutoDismiss;
5509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the data for the Intent that will be issued when the user clicks on the
5549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendation.
5559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An IntentData object, containing the data for the Intent that gets issued when the
5579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         recommendation is clicked on.
5589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public IntentData getContentIntent() {
5609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mContentIntentData;
5619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the data for the Intent that will be issued when the recommendation gets dismissed
5659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * from the Home Screen, due to an user action.
5669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An IntentData object, containing the data for the Intent that gets issued when the
5689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         recommendation is dismissed from the Home Screen.
5699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public IntentData getDismissIntent() {
5719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mDismissIntentData;
5729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns an array containing the content types tags that describe the content. The first tag
5769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * entry is considered the primary type for the content, and is used for content ranking
5779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * purposes.
5789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An array of predefined type tags (see the <code>CONTENT_TYPE_*</code> constants) that
5809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         describe the recommended content.
5819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String[] getContentTypes() {
5839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mContentTypes != null) {
5849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return Arrays.copyOf(mContentTypes, mContentTypes.length);
5859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
5869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mContentTypes;
5879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
5889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
5899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
5909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the primary content type tag for the recommendation, or null if no content types have
5919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * been specified.
5929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
5939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A predefined type tag (see the <code>CONTENT_TYPE_*</code> constants) indicating the
5949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         primary content type for the recommendation.
5959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
5969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getPrimaryContentType() {
5979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mContentTypes != null && mContentTypes.length > 0) {
5989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return mContentTypes[0];
5999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
6009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return null;
6019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns an array containing the genres that describe the content. Genres are open ended
6059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * String tags.
6069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return An array of genre tags that describe the recommended content.
6089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String[] getGenres() {
6109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mContentGenres != null) {
6119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return Arrays.copyOf(mContentGenres, mContentGenres.length);
6129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
6139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mContentGenres;
6149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Gets the pricing type for the content.
6189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A predefined tag indicating the pricing type for the content (see the <code>
6209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         CONTENT_PRICING_*</code> constants).
6219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getPricingType() {
6239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mPriceType;
6249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Gets the price value (when applicable) for the content. The value will be provided as a
6289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * String containing the price in the appropriate currency for the current locale.
6299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A string containing a representation of the content price in the current locale and
6319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         currency.
6329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getPricingValue() {
6349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mPriceValue;
6359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Sets the availability status value for the content. This status indicates whether the content
6399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * is ready to be consumed on the device, or if the user must first purchase, rent, subscribe
6409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * to, or download the content.
6419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param status The status value for the content. (see the <code>CONTENT_STATUS_*</code> for
6439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *            the valid status values).
6449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public void setStatus(@ContentStatus int status) {
6469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        mStatus = status;
6479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns availability status value for the content. This status indicates whether the content
6519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * is ready to be consumed on the device, or if the user must first purchase, rent, subscribe
6529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * to, or download the content.
6539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return The status value for the content, or -1 is a valid status has not been specified (see
6559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         the <code>CONTENT_STATUS_*</code> constants for the valid status values).
6569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int getStatus() {
6589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mStatus;
6599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the maturity level rating for the content.
6639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return returns a predefined tag indicating the maturity level rating for the content (see
6659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         the <code>CONTENT_MATURITY_*</code> constants).
6669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public String getMaturityRating() {
6689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mMaturityRating;
6699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns the running time for the content.
6739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
6749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return The run length, in seconds, of the content associated with the notification.
6759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
6769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public long getRunningTime() {
6779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return mRunningTime;
6789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @Override
6819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public boolean equals(Object other) {
6829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (other instanceof ContentRecommendation) {
6839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return TextUtils.equals(mIdTag, ((ContentRecommendation) other).getIdTag());
6849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
6859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return false;
6869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    @Override
6899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public int hashCode() {
6909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mIdTag != null) {
6919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return mIdTag.hashCode();
6929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
6939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return Integer.MAX_VALUE;
6949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
6959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
6969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
6979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Builder class for {@link ContentRecommendation} objects. Provides a convenient way to set the
6989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * various fields of a {@link ContentRecommendation}.
6999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <p>
7009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Example:
7019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
7029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * <pre class="prettyprint">
7039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * ContentRecommendation rec = new ContentRecommendation.Builder()
7049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setIdInfo(id, &quot;MyTagId&quot;)
7059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setTitle(&quot;My Content Recommendation&quot;)
7069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setText(&quot;An example of content recommendation&quot;)
7079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setContentImage(myBitmap)
7089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setBadgeIcon(R.drawable.app_icon)
7099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .setGroup(&quot;Trending&quot;)
7109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         .build();
7119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * </pre>
7129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
7139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public static final class Builder {
7149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderIdTag;
7159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderTitle;
7169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderText;
7179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderSourceName;
7189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private Bitmap mBuilderContentImage;
7199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private int mBuilderBadgeIconId;
7209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderBackgroundImageUri;
7219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private int mBuilderColor;
7229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderGroup;
7239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderSortKey;
7249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private int mBuilderProgressAmount;
7259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private int mBuilderProgressMax;
7269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private boolean mBuilderAutoDismiss;
7279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private IntentData mBuilderContentIntentData;
7289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private IntentData mBuilderDismissIntentData;
7299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String[] mBuilderContentTypes;
7309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String[] mBuilderContentGenres;
7319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderPriceType;
7329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderPriceValue;
7339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private int mBuilderStatus;
7349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private String mBuilderMaturityRating;
7359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        private long mBuilderRunningTime;
7369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Constructs a new Builder.
7399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder() {
7429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
7439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the Id tag that uniquely identifies this recommendation object.
7469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param idTag A String tag identifier for this recommendation.
7489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
7499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setIdTag(String idTag) {
7519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderIdTag = checkNotNull(idTag);
7529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
7539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
7549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the content title for the recommendation.
7579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param title A String containing the recommendation content title.
7599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
7609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setTitle(String title) {
7629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderTitle = checkNotNull(title);
7639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
7649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
7659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the description text for the recommendation.
7689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param description A String containing the recommendation description text.
7709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
7719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setText(@Nullable String description) {
7739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderText = description;
7749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
7759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
7769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the source application name for the recommendation.
7799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <P>
7809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * If the source name is never set, or set to null, the application name retrieved from its
7819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * package will be used by default.
7829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param source A String containing the recommendation source name.
7849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
7859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setSourceName(@Nullable String source) {
7879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderSourceName = source;
7889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
7899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
7909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
7919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
7929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the recommendation image.
7939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
7949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param image A Bitmap containing the recommendation image.
7959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
7969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
7979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setContentImage(Bitmap image) {
7989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentImage = checkNotNull(image);
7999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the resource ID for the recommendation badging icon.
8049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
8059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * The resource id represents the icon resource in the source application package. If not
8069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * set, or an invalid resource ID is specified, the application icon retrieved from its
8079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * package will be used by default.
8089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param iconResourceId An integer id for the badge icon resource.
8109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
812b8b0f576954dec949a86ca72e0740dcb2dfdc550Tor Norbye        public Builder setBadgeIcon(@DrawableRes int iconResourceId) {
8139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderBadgeIconId = iconResourceId;
8149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the Content URI that will be used to retrieve the background image for the
8199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * recommendation.
8209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param imageUri A Content URI pointing to the recommendation background image.
8229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
8249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setBackgroundImageUri(@Nullable String imageUri) {
8259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderBackgroundImageUri = imageUri;
8269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the accent color value to be used in the UI when displaying this content
8319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * recommendation to the user.
8329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param color An integer value representing the accent color for this recommendation.
8349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
836b8b0f576954dec949a86ca72e0740dcb2dfdc550Tor Norbye        public Builder setColor(@ColorInt int color) {
8379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderColor = color;
8389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the String group ID tag for the recommendation.
8439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
8449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Recommendations in the same group are ranked by the Home Screen together, and the sort
8459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * order within a group is respected. This can be useful if the application has different
8469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * sources for recommendations, like "trending", "subscriptions", and "new music" categories
8479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * for YouTube, where the user can be more interested in recommendations from one group than
8489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * another.
8499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param groupTag A String containing the group ID tag for this recommendation.
8519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
8539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setGroup(@Nullable String groupTag) {
8549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderGroup = groupTag;
8559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the String sort key for the recommendation.
8609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
8619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * The sort key must be a String representation of a float number between 0.0 and 1.0, and
8629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * is used to indicate the relative importance (and sort order) of a single recommendation
8639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * within its specified group. The recommendations will be ordered in decreasing order of
8649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * importance within a given group.
8659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param sortKey A String containing the sort key for this recommendation.
8679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
8699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setSortKey(@Nullable String sortKey) {
8709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderSortKey = sortKey;
8719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the progress information for the content pointed to by the recommendation.
8769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param max The maximum value for the progress of this content.
8789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param progress The progress amount for this content. Must be in the range (0 - max).
8799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
8819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setProgress(int max, int progress) {
8829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (max < 0 || progress < 0) {
8839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                throw new IllegalArgumentException();
8849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
8859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderProgressMax = max;
8869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderProgressAmount = progress;
8879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
8889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
8899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
8909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
8919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the flag indicating if the recommendation should be dismissed automatically.
8929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
8939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Auto-dismiss notifications are automatically removed from the Home Screen when the user
8949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * clicks on them.
8959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
8969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param autoDismiss A boolean indicating if the recommendation should be auto dismissed or
8979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            not.
8989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
8999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
9009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setAutoDismiss(boolean autoDismiss) {
9019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderAutoDismiss = autoDismiss;
9029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
9039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
9049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
9069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the data for the Intent that will be issued when the user clicks on the
9079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * recommendation.
9089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
9099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * The Intent data fields provided correspond to the fields passed into the
9109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * {@link PendingIntent} factory methods, when creating a new PendingIntent. The actual
9119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * PengindIntent object will only be created at the time a recommendation is posted to the
9129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Home Screen.
9139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
9149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param intentType The type of {@link PendingIntent} to be created when posting this
9159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            recommendation.
9169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param intent The Intent which to be issued when the recommendation is clicked on.
9179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param requestCode The private request code to be used when creating the
9189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            {@link PendingIntent}
9199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param options Only used for the Activity Intent type. Additional options for how the
9209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            Activity should be started. May be null if there are no options.
9219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
9229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
9239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setContentIntentData(@IntentType int intentType, Intent intent,
9249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                int requestCode, @Nullable Bundle options) {
9259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (intentType != INTENT_TYPE_ACTIVITY &&
9269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                    intentType != INTENT_TYPE_BROADCAST &&
9279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                    intentType != INTENT_TYPE_SERVICE) {
9289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                throw new IllegalArgumentException("Invalid Intent type specified.");
9299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
9309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentIntentData = new IntentData();
9329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentIntentData.mType = intentType;
9339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentIntentData.mIntent = checkNotNull(intent);
9349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentIntentData.mRequestCode = requestCode;
9359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentIntentData.mOptions = options;
9369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
9389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
9399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
9419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the data for the Intent that will be issued when the recommendation gets dismissed
9429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * from the Home Screen, due to an user action.
9439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
9449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * The Intent data fields provided correspond to the fields passed into the
9459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * {@link PendingIntent} factory methods, when creating a new PendingIntent. The actual
9469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * PengindIntent object will only be created at the time a recommendation is posted to the
9479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Home Screen.
9489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
9499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param intentType The type of {@link PendingIntent} to be created when posting this
9509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            recommendation.
9519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param intent The Intent which gets issued when the recommendation is dismissed from the
9529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            Home Screen.
9539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param requestCode The private request code to be used when creating the
9549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            {@link PendingIntent}
9559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param options Only used for the Activity Intent type. Additional options for how the
9569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            Activity should be started. May be null if there are no options.
9579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @return The Builder object, for chaining.
9589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
9599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setDismissIntentData(@IntentType int intentType, @Nullable Intent intent,
9609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                int requestCode, @Nullable Bundle options) {
9619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (intent != null) {
9629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                if (intentType != INTENT_TYPE_ACTIVITY &&
9639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        intentType != INTENT_TYPE_BROADCAST &&
9649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        intentType != INTENT_TYPE_SERVICE) {
9659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                    throw new IllegalArgumentException("Invalid Intent type specified.");
9669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                }
9679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData = new IntentData();
9699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData.mType = intentType;
9709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData.mIntent = intent;
9719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData.mRequestCode = requestCode;
9729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData.mOptions = options;
9739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            } else {
9749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                mBuilderDismissIntentData = null;
9759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
9769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
9779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
9789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
9809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the content types associated with the content recommendation. The first tag entry
9819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * will be considered the primary type for the content and will be used for ranking
9829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * purposes. Other secondary type tags may be provided, if applicable, and may be used for
9839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * filtering purposes.
9849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
9859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param types Array of predefined type tags (see the <code>CONTENT_TYPE_*</code>
9869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            constants) that describe the recommended content.
9879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
9889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setContentTypes(String[] types) {
9899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentTypes = checkNotNull(types);
9909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
9919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
9929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
9939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
9949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the content genres for the recommendation. These genres may be used for content
9959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * ranking. Genres are open ended String tags.
9969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * <p>
9979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Some examples: "comedy", "action", "dance", "electronica", "racing", etc.
9989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
9999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param genres Array of genre string tags that describe the recommended content.
10009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setGenres(String[] genres) {
10029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderContentGenres = genres;
10039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
10049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
10079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the pricing and availability information for the recommendation. The provided
10089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * information will indicate the access model for the content (free, rental, purchase or
10099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * subscription) and the price value (if not free).
10109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
10119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param priceType Pricing type for this content. Must be one of the predefined pricing
10129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            type tags (see the <code>CONTENT_PRICING_*</code> constants).
10139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param priceValue A string containing a representation of the content price in the
10149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            current locale and currency.
10159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setPricingInformation(@ContentPricing String priceType,
10179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                @Nullable String priceValue) {
10189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderPriceType = checkNotNull(priceType);
10199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderPriceValue = priceValue;
10209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
10219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
10249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the availability status for the content. This status indicates whether the referred
10259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * content is ready to be consumed on the device, or if the user must first purchase, rent,
10269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * subscribe to, or download the content.
10279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
10289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param contentStatus The status value for this content. Must be one of the predefined
10299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            content status values (see the <code>CONTENT_STATUS_*</code> constants).
10309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setStatus(@ContentStatus int contentStatus) {
10329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderStatus = contentStatus;
10339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
10349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
10379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the maturity level rating for the content.
10389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
10399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param maturityRating A tag indicating the maturity level rating for the content. This
10409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            tag must be one of the predefined maturity rating tags (see the <code>
10419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *            CONTENT_MATURITY_*</code> constants).
10429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setMaturityRating(@ContentMaturity String maturityRating) {
10449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderMaturityRating = checkNotNull(maturityRating);
10459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
10469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
10499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Sets the running time (when applicable) for the content.
10509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         *
10519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * @param length The running time, in seconds, of the content.
10529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public Builder setRunningTime(long length) {
10549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (length < 0) {
10559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                throw new IllegalArgumentException();
10569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
10579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            mBuilderRunningTime = length;
10589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return this;
10599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        /**
10629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * Combine all of the options that have been set and return a new
10639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         * {@link ContentRecommendation} object.
10649f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima         */
10659f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        public ContentRecommendation build() {
10669f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            return new ContentRecommendation(this);
10679f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10689f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
10699f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10709f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
10719f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Returns a {@link android.app.Notification Notification} object which contains the content
10729f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendation data encapsulated by this object, which can be used for posting the
10739f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * recommendation via the {@link android.app.NotificationManager NotificationManager}.
10749f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
10759f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param context A {@link Context} that will be used to construct the
10769f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *            {@link android.app.Notification Notification} object which will carry the
10779f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *            recommendation data.
10789f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return A {@link android.app.Notification Notification} containing the stored recommendation
10799f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *         data.
10809f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
10819f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    public Notification getNotificationObject(Context context) {
10829f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        Notification.Builder builder = new Notification.Builder(context);
10839f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        RecommendationExtender recExtender = new RecommendationExtender();
10849f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10859f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        // Encode all the content recommendation data in a Notification object
10869f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
10879f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setCategory(Notification.CATEGORY_RECOMMENDATION);
10889f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setContentTitle(mTitle);
10899f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setContentText(mText);
10909f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setContentInfo(mSourceName);
10919f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setLargeIcon(mContentImage);
10929f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setSmallIcon(mBadgeIconId);
10939f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mBackgroundImageUri != null) {
10949f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            builder.getExtras().putString(Notification.EXTRA_BACKGROUND_IMAGE_URI,
10959f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                    mBackgroundImageUri);
10969f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
10979f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setColor(mColor);
10989f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setGroup(mGroup);
10999f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setSortKey(mSortKey);
11009f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setProgress(mProgressMax, mProgressAmount, false);
11019f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.setAutoCancel(mAutoDismiss);
11029f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11039f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mContentIntentData != null) {
11049f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            PendingIntent contentPending;
11059f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (mContentIntentData.mType == INTENT_TYPE_ACTIVITY) {
11069f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                contentPending = PendingIntent.getActivity(context, mContentIntentData.mRequestCode,
11079f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mContentIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT,
11089f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mContentIntentData.mOptions);
11099f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            } else if (mContentIntentData.mType == INTENT_TYPE_SERVICE) {
11109f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                contentPending = PendingIntent.getService(context, mContentIntentData.mRequestCode,
11119f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mContentIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
11129f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            } else { // Default:INTENT_TYPE_BROADCAST{
11139f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                contentPending = PendingIntent.getBroadcast(context,
11149f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mContentIntentData.mRequestCode,
11159f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mContentIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
11169f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
11179f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            builder.setContentIntent(contentPending);
11189f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
11199f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11209f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (mDismissIntentData != null) {
11219f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            PendingIntent dismissPending;
11229f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            if (mDismissIntentData.mType == INTENT_TYPE_ACTIVITY) {
11239f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                dismissPending = PendingIntent.getActivity(context, mDismissIntentData.mRequestCode,
11249f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mDismissIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT,
11259f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mDismissIntentData.mOptions);
11269f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            } else if (mDismissIntentData.mType == INTENT_TYPE_SERVICE) {
11279f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                dismissPending = PendingIntent.getService(context, mDismissIntentData.mRequestCode,
11289f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mDismissIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
11299f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            } else { // Default:INTENT_TYPE_BROADCAST{
11309f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                dismissPending = PendingIntent.getBroadcast(context,
11319f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mDismissIntentData.mRequestCode,
11329f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima                        mDismissIntentData.mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
11339f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            }
11349f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            builder.setDeleteIntent(dismissPending);
11359f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
11369f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11379f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setContentTypes(mContentTypes);
11389f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setGenres(mContentGenres);
11399f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setPricingInformation(mPriceType, mPriceValue);
11409f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setStatus(mStatus);
11419f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setMaturityRating(mMaturityRating);
11429f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        recExtender.setRunningTime(mRunningTime);
11439f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11449f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        builder.extend(recExtender);
11459f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        Notification notif = builder.build();
11469f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return notif;
11479f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
11489f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11499f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    /**
11509f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * Ensures that an object reference passed as a parameter to the calling method is not null.
11519f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     *
11529f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @param reference an object reference
11539f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @return the non-null reference that was validated
11549f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     * @throws NullPointerException if {@code reference} is null
11559f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima     */
11569f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    private static <T> T checkNotNull(final T reference) {
11579f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        if (reference == null) {
11589f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima            throw new NullPointerException();
11599f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        }
11609f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima        return reference;
11619f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima    }
11629f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima
11639f7b11d8713c9c9dcaa3a308f01604897bfe4677Jose Lima}