Search in sources :

Example 1 with Show

use of com.uwetrottmann.seriesguide.backend.shows.model.Show in project SeriesGuide by UweTrottmann.

the class ShowTools method sendIsAdded.

/**
     * Adds the show on Hexagon. Or if it does already exist, clears the isRemoved flag and updates
     * the language, so the show will be auto-added on other connected devices.
     */
public void sendIsAdded(int showTvdbId, @NonNull String language) {
    Show show = new Show();
    show.setTvdbId(showTvdbId);
    show.setLanguage(language);
    show.setIsRemoved(false);
    uploadShowAsync(show);
}
Also used : Show(com.uwetrottmann.seriesguide.backend.shows.model.Show)

Example 2 with Show

use of com.uwetrottmann.seriesguide.backend.shows.model.Show in project SeriesGuide by UweTrottmann.

the class ShowTools method storeIsHidden.

/**
     * Saves new hidden flag to the local database and, if signed in, up into the cloud as well.
     */
public void storeIsHidden(int showTvdbId, boolean isHidden) {
    if (HexagonSettings.isEnabled(app)) {
        if (Utils.isNotConnected(app, true)) {
            return;
        }
        // send to cloud
        Show show = new Show();
        show.setTvdbId(showTvdbId);
        show.setIsHidden(isHidden);
        uploadShowAsync(show);
    }
    // save to local database
    ContentValues values = new ContentValues();
    values.put(SeriesGuideContract.Shows.HIDDEN, isHidden);
    app.getContentResolver().update(SeriesGuideContract.Shows.buildShowUri(showTvdbId), values, null, null);
    // also notify filter URI used by search
    app.getContentResolver().notifyChange(SeriesGuideContract.Shows.CONTENT_URI_FILTER, null);
    Toast.makeText(app, app.getString(isHidden ? R.string.hidden : R.string.unhidden), Toast.LENGTH_SHORT).show();
}
Also used : ContentValues(android.content.ContentValues) Show(com.uwetrottmann.seriesguide.backend.shows.model.Show)

Example 3 with Show

use of com.uwetrottmann.seriesguide.backend.shows.model.Show in project SeriesGuide by UweTrottmann.

the class ShowTools method storeLanguage.

public void storeLanguage(final int showTvdbId, final String languageCode) {
    if (HexagonSettings.isEnabled(app)) {
        if (Utils.isNotConnected(app, true)) {
            return;
        }
        // send to cloud
        Show show = new Show();
        show.setTvdbId(showTvdbId);
        show.setLanguage(languageCode);
        uploadShowAsync(show);
    }
    // schedule database update and sync
    Runnable runnable = new Runnable() {

        public void run() {
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
            // change language
            ContentValues values = new ContentValues();
            values.put(SeriesGuideContract.Shows.LANGUAGE, languageCode);
            app.getContentResolver().update(SeriesGuideContract.Shows.buildShowUri(showTvdbId), values, null, null);
            // reset episode last edit time so all get updated
            values = new ContentValues();
            values.put(SeriesGuideContract.Episodes.LAST_EDITED, 0);
            app.getContentResolver().update(SeriesGuideContract.Episodes.buildEpisodesOfShowUri(showTvdbId), values, null, null);
            // trigger update
            SgSyncAdapter.requestSyncImmediate(app, SgSyncAdapter.SyncType.SINGLE, showTvdbId, false);
        }
    };
    AsyncTask.THREAD_POOL_EXECUTOR.execute(runnable);
    // show immediate feedback, also if offline and sync won't go through
    if (AndroidUtils.isNetworkConnected(app)) {
        // notify about upcoming sync
        Toast.makeText(app, R.string.update_scheduled, Toast.LENGTH_SHORT).show();
    } else {
        // offline
        Toast.makeText(app, R.string.update_no_connection, Toast.LENGTH_LONG).show();
    }
}
Also used : ContentValues(android.content.ContentValues) Show(com.uwetrottmann.seriesguide.backend.shows.model.Show)

Example 4 with Show

use of com.uwetrottmann.seriesguide.backend.shows.model.Show in project SeriesGuide by UweTrottmann.

the class ShowTools method sendIsRemoved.

/**
     * Sets the isRemoved flag of the given show on Hexagon, so the show will not be auto-added on
     * any device connected to Hexagon.
     */
public void sendIsRemoved(int showTvdbId) {
    Show show = new Show();
    show.setTvdbId(showTvdbId);
    show.setIsRemoved(true);
    uploadShowAsync(show);
}
Also used : Show(com.uwetrottmann.seriesguide.backend.shows.model.Show)

Example 5 with Show

use of com.uwetrottmann.seriesguide.backend.shows.model.Show in project SeriesGuide by UweTrottmann.

the class ShowTools method storeIsFavorite.

/**
     * Saves new favorite flag to the local database and, if signed in, up into the cloud as well.
     */
public void storeIsFavorite(int showTvdbId, boolean isFavorite) {
    if (HexagonSettings.isEnabled(app)) {
        if (Utils.isNotConnected(app, true)) {
            return;
        }
        // send to cloud
        Show show = new Show();
        show.setTvdbId(showTvdbId);
        show.setIsFavorite(isFavorite);
        uploadShowAsync(show);
    }
    // save to local database
    ContentValues values = new ContentValues();
    values.put(SeriesGuideContract.Shows.FAVORITE, isFavorite);
    app.getContentResolver().update(SeriesGuideContract.Shows.buildShowUri(showTvdbId), values, null, null);
    // also notify URIs used by search and lists
    app.getContentResolver().notifyChange(SeriesGuideContract.Shows.CONTENT_URI_FILTER, null);
    app.getContentResolver().notifyChange(SeriesGuideContract.ListItems.CONTENT_WITH_DETAILS_URI, null);
    // favorite status may determine eligibility for notifications
    Utils.runNotificationService(app);
    Toast.makeText(app, app.getString(isFavorite ? R.string.favorited : R.string.unfavorited), Toast.LENGTH_SHORT).show();
}
Also used : ContentValues(android.content.ContentValues) Show(com.uwetrottmann.seriesguide.backend.shows.model.Show)

Aggregations

Show (com.uwetrottmann.seriesguide.backend.shows.model.Show)7 ContentValues (android.content.ContentValues)3 SgCloudShow (com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShow)2 Nullable (androidx.annotation.Nullable)1 TmdbTools2 (com.battlelancer.seriesguide.tmdbapi.TmdbTools2)1 Shows (com.uwetrottmann.seriesguide.backend.shows.Shows)1 SgCloudShowList (com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShowList)1 ShowList (com.uwetrottmann.seriesguide.backend.shows.model.ShowList)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1