Search in sources :

Example 6 with LoaderManager

use of androidx.loader.app.LoaderManager in project SeriesGuide by UweTrottmann.

the class ShowsNowFragment method initAndMaybeRestartLoader.

/**
 * Init the loader. If the loader already exists, will restart it (the default behavior of init
 * would be to get the last loaded data).
 */
private <D> void initAndMaybeRestartLoader(int loaderId, LoaderManager.LoaderCallbacks<D> callbacks) {
    LoaderManager loaderManager = LoaderManager.getInstance(this);
    boolean isLoaderExists = loaderManager.getLoader(loaderId) != null;
    loaderManager.initLoader(loaderId, null, callbacks);
    if (isLoaderExists) {
        loaderManager.restartLoader(loaderId, null, callbacks);
    }
}
Also used : LoaderManager(androidx.loader.app.LoaderManager)

Aggregations

LoaderManager (androidx.loader.app.LoaderManager)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)2