List of usage examples for android.media Rating RATING_5_STARS
int RATING_5_STARS
To view the source code for android.media Rating RATING_5_STARS.
Click Source Link
From source file:com.example.android.tvleanback.data.VideoDbBuilder.java
/** * Takes the contents of a JSON object and populates the database * @param jsonObj The JSON object of videos * @throws JSONException if the JSON object is invalid *//*from w w w.jav a2 s . com*/ public List<ContentValues> buildMedia(JSONObject jsonObj) throws JSONException { JSONArray categoryArray = jsonObj.getJSONArray(TAG_GOOGLE_VIDEOS); List<ContentValues> videosToInsert = new ArrayList<>(); for (int i = 0; i < categoryArray.length(); i++) { JSONArray videoArray; JSONObject category = categoryArray.getJSONObject(i); String categoryName = category.getString(TAG_CATEGORY); videoArray = category.getJSONArray(TAG_MEDIA); for (int j = 0; j < videoArray.length(); j++) { JSONObject video = videoArray.getJSONObject(j); // If there are no URLs, skip this video entry. JSONArray urls = video.optJSONArray(TAG_SOURCES); if (urls == null || urls.length() == 0) { continue; } String title = video.optString(TAG_TITLE); String description = video.optString(TAG_DESCRIPTION); String videoUrl = (String) urls.get(0); // Get the first video only. String bgImageUrl = video.optString(TAG_BACKGROUND); String cardImageUrl = video.optString(TAG_CARD_THUMB); String studio = video.optString(TAG_STUDIO); ContentValues videoValues = new ContentValues(); videoValues.put(VideoContract.VideoEntry.COLUMN_CATEGORY, categoryName); videoValues.put(VideoContract.VideoEntry.COLUMN_NAME, title); videoValues.put(VideoContract.VideoEntry.COLUMN_DESC, description); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_URL, videoUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_CARD_IMG, cardImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_BG_IMAGE_URL, bgImageUrl); videoValues.put(VideoContract.VideoEntry.COLUMN_STUDIO, studio); // Fixed defaults. videoValues.put(VideoContract.VideoEntry.COLUMN_CONTENT_TYPE, "video/mp4"); videoValues.put(VideoContract.VideoEntry.COLUMN_IS_LIVE, false); videoValues.put(VideoContract.VideoEntry.COLUMN_AUDIO_CHANNEL_CONFIG, "2.0"); videoValues.put(VideoContract.VideoEntry.COLUMN_PRODUCTION_YEAR, 2014); videoValues.put(VideoContract.VideoEntry.COLUMN_DURATION, 0); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_STYLE, Rating.RATING_5_STARS); videoValues.put(VideoContract.VideoEntry.COLUMN_RATING_SCORE, 3.5f); if (mContext != null) { videoValues.put(VideoContract.VideoEntry.COLUMN_PURCHASE_PRICE, mContext.getResources().getString(R.string.buy_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_RENTAL_PRICE, mContext.getResources().getString(R.string.rent_2)); videoValues.put(VideoContract.VideoEntry.COLUMN_ACTION, mContext.getResources().getString(R.string.global_search)); } // TODO: Get these dimensions. videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_WIDTH, 1280); videoValues.put(VideoContract.VideoEntry.COLUMN_VIDEO_HEIGHT, 720); videosToInsert.add(videoValues); } } return videosToInsert; }