Search in sources :

Example 86 with ContentValues

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;
}
Also used : ContentValues(android.content.ContentValues) Date(java.util.Date)

Example 87 with ContentValues

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;
}
Also used : ContentValues(android.content.ContentValues) Uri(android.net.Uri)

Example 88 with ContentValues

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;
}
Also used : ContentValues(android.content.ContentValues)

Example 89 with ContentValues

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;
}
Also used : ContentValues(android.content.ContentValues) ListsActivity(com.battlelancer.seriesguide.ui.ListsActivity)

Example 90 with ContentValues

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);
}
Also used : ContentValues(android.content.ContentValues) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) Document(org.w3c.dom.Document) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Bitmap(android.graphics.Bitmap) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) Dialog(android.app.Dialog) AdapterView(android.widget.AdapterView) OnBitmapResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnBitmapResponseListener) ImageView(android.widget.ImageView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ContentValues (android.content.ContentValues)3993 Cursor (android.database.Cursor)720 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)638 Uri (android.net.Uri)619 Test (org.junit.Test)374 SQLException (android.database.SQLException)231 ContentResolver (android.content.ContentResolver)212 ArrayList (java.util.ArrayList)192 Intent (android.content.Intent)162 File (java.io.File)156 IOException (java.io.IOException)131 RemoteException (android.os.RemoteException)96 CursorAssert.assertThatCursor (org.hisp.dhis.android.core.data.database.CursorAssert.assertThatCursor)91 NonNull (android.support.annotation.NonNull)74 Date (java.util.Date)73 MediumTest (android.test.suitebuilder.annotation.MediumTest)63 HashMap (java.util.HashMap)62 JSONException (org.json.JSONException)60 SQLiteException (android.database.sqlite.SQLiteException)53 ContentProviderOperation (android.content.ContentProviderOperation)49