use of android.content.ContentValues in project SeriesGuide by UweTrottmann.
the class MovieTools method buildBasicMovieContentValues.
/**
* Extracts ratings from trakt, all other properties from TMDb data.
*
* <p> If either movie data is null, will still extract the properties of others.
*/
public static ContentValues buildBasicMovieContentValues(MovieDetails details) {
ContentValues values = new ContentValues();
// data from trakt
if (details.traktRatings() != null) {
values.put(SeriesGuideContract.Movies.RATING_TRAKT, details.traktRatings().rating);
values.put(SeriesGuideContract.Movies.RATING_VOTES_TRAKT, details.traktRatings().votes);
}
// data from TMDb
if (details.tmdbMovie() != null) {
values.put(SeriesGuideContract.Movies.IMDB_ID, details.tmdbMovie().imdb_id);
values.put(SeriesGuideContract.Movies.TITLE, details.tmdbMovie().title);
values.put(SeriesGuideContract.Movies.TITLE_NOARTICLE, DBUtils.trimLeadingArticle(details.tmdbMovie().title));
values.put(SeriesGuideContract.Movies.OVERVIEW, details.tmdbMovie().overview);
values.put(SeriesGuideContract.Movies.POSTER, details.tmdbMovie().poster_path);
values.put(SeriesGuideContract.Movies.RUNTIME_MIN, details.tmdbMovie().runtime);
values.put(SeriesGuideContract.Movies.RATING_TMDB, details.tmdbMovie().vote_average);
values.put(SeriesGuideContract.Movies.RATING_VOTES_TMDB, details.tmdbMovie().vote_count);
// if there is no release date, store Long.MAX as it is likely in the future
// also helps correctly sorting movies by release date
Date releaseDate = details.tmdbMovie().release_date;
values.put(SeriesGuideContract.Movies.RELEASED_UTC_MS, releaseDate == null ? Long.MAX_VALUE : releaseDate.getTime());
}
return values;
}
use of android.content.ContentValues in project SeriesGuide by UweTrottmann.
the class MovieTools method addMovieWatchedShell.
/**
* Inserts a movie shell into the database only holding TMDB id, list and watched states.
*/
private static boolean addMovieWatchedShell(Context context, int movieTmdbId) {
ContentValues values = new ContentValues();
values.put(SeriesGuideContract.Movies.TMDB_ID, movieTmdbId);
values.put(SeriesGuideContract.Movies.IN_COLLECTION, false);
values.put(SeriesGuideContract.Movies.IN_WATCHLIST, false);
values.put(SeriesGuideContract.Movies.WATCHED, true);
Uri insert = context.getContentResolver().insert(SeriesGuideContract.Movies.CONTENT_URI, values);
return insert != null;
}
use of android.content.ContentValues in project SeriesGuide by UweTrottmann.
the class RateShowTask method doDatabaseUpdate.
@Override
protected boolean doDatabaseUpdate() {
ContentValues values = new ContentValues();
values.put(SeriesGuideContract.Shows.RATING_USER, getRating().value);
int rowsUpdated = getContext().getContentResolver().update(SeriesGuideContract.Shows.buildShowUri(showTvdbId), values, null, null);
return rowsUpdated > 0;
}
use of android.content.ContentValues in project SeriesGuide by UweTrottmann.
the class RenameListTask method doDatabaseUpdate.
@Override
protected boolean doDatabaseUpdate(String listId) {
ContentValues values = new ContentValues();
values.put(SeriesGuideContract.Lists.NAME, listName);
int updated = getContext().getContentResolver().update(SeriesGuideContract.Lists.buildListUri(listId), values, null, null);
if (updated == 0) {
return false;
}
// notify lists activity
EventBus.getDefault().post(new ListsActivity.ListsChangedEvent());
return true;
}
use of android.content.ContentValues in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class PlaceActivity3 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_1);
textStatus = (TextView) findViewById(R.id.textStatus);
listView = (ListView) findViewById(R.id.listView);
gp = new GooglePlaceSearch(ApiKey);
gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {
public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
textStatus.setText("Status : " + status);
if (status.equals(GooglePlaceSearch.STATUS_OK)) {
ArrayList<String> array = new ArrayList<String>();
final ArrayList<String> array_photo = new ArrayList<String>();
for (int i = 0; i < arr_data.size(); i++) {
array.add("Name : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME) + "\n" + "Address : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_ADDRESS) + "\n" + "Latitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LATITUDE) + "\n" + "Longitude : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_LONGITUDE) + "\n" + "Phone Number : " + arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHONENUMBER));
array_photo.add(arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_PHOTO));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(PlaceActivity3.this, R.layout.listview_text, array);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Dialog dialog = new Dialog(PlaceActivity3.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_photo);
dialog.setCancelable(true);
final ImageView imgPhoto = (ImageView) dialog.findViewById(R.id.imgPhoto);
dialog.show();
gp.getPhotoBitmapByWidth(array_photo.get(arg2), 600, "", new OnBitmapResponseListener() {
public void onResponse(Bitmap bm, String tag) {
imgPhoto.setImageBitmap(bm);
}
});
}
});
}
}
});
gp.getNearby(latitude, longitude, radius, type, language, keyword);
}
Aggregations