@Override public ContentValues convertToContentValue(Film object) { ContentValues values = new ContentValues(); values.put(MovieEntry.Cols.MOVIE_ID, object.getId()); values.put(MovieEntry.Cols.TITLE, object.getTitle()); values.put(MovieEntry.Cols.OVERVIEW, object.getOverview()); values.put(MovieEntry.Cols.RELEASE_DATE, object.getReleaseDate()); values.put(MovieEntry.Cols.LENGTH, 0); values.put(MovieEntry.Cols.USER_VOTING, object.getVoteAverage()); values.put(MovieEntry.Cols.PROGRAM_TYPE, object.getProgramType()); values.put(MovieEntry.Cols.POSTER_PATH, object.getPosterPath()); values.put(MovieEntry.Cols.LANGUAGE_KEY, object.getLanguage()); return values; }
@Override public Film convertJsonObjectToObject(JSONObject jsonObject) { Film film = new Film(); try { film.setId(jsonObject.getInt("id")); film.setTitle(jsonObject.getString("original_title")); film.setLanguage(jsonObject.getString("original_language")); film.setReleaseDate(convertDateStrToLongType(jsonObject.getString("release_date"))); film.setVoteAverage(jsonObject.getDouble("vote_average")); film.setProgramType(GlobalVariable.MOVIE_PROGRAM); film.setOverview(jsonObject.getString("overview")); film.setPosterPath(jsonObject.getString("poster_path")); } catch (JSONException e) { Log.e(TAG, "Failed to set date into object", e); } insert(jsonObject); return film; }