Search in sources :

Example 1 with AddShowTask

use of com.battlelancer.seriesguide.ui.search.AddShowTask in project SeriesGuide by UweTrottmann.

the class TaskManager method performAddTask.

/**
 * Schedule shows to be added to the database.
 *
 * @param isSilentMode   Whether to display status toasts if a show could not be added.
 * @param isMergingShows Whether to set the Hexagon show merged flag to true if all shows were
 */
@MainThread
public synchronized void performAddTask(final Context context, final List<SearchResult> shows, final boolean isSilentMode, final boolean isMergingShows) {
    if (!isSilentMode) {
        // notify user here already
        if (shows.size() == 1) {
            // say title of show
            SearchResult show = shows.get(0);
            Toast.makeText(context, context.getString(R.string.add_started, show.getTitle()), Toast.LENGTH_SHORT).show();
        } else {
            // generic adding multiple message
            Toast.makeText(context, R.string.add_multiple, Toast.LENGTH_SHORT).show();
        }
    }
    // noinspection ConstantConditions: null check in isAddTaskRunning
    if (!isAddTaskRunning() || !addShowTask.addShows(shows, isSilentMode, isMergingShows)) {
        addShowTask = new AddShowTask(context, shows, isSilentMode, isMergingShows);
        addShowTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : AddShowTask(com.battlelancer.seriesguide.ui.search.AddShowTask) SearchResult(com.battlelancer.seriesguide.ui.search.SearchResult) MainThread(androidx.annotation.MainThread)

Aggregations

MainThread (androidx.annotation.MainThread)1 AddShowTask (com.battlelancer.seriesguide.ui.search.AddShowTask)1 SearchResult (com.battlelancer.seriesguide.ui.search.SearchResult)1