app/src/main/java/io/github/ilya_lebedev/popularmovies/MainActivity.java
/**
     * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader created.
     *
     * @param loaderId The loader ID
     * @param bundle   Arguments
     *
     * @return A new Loader instance
     */
Called by the  android.support.v4.app.LoaderManagerImpl when a new Loader created.
@param loaderId The loader ID
@param bundle   Arguments

@return A new Loader instance
Called by the android . support . v4 . app . LoaderManagerImpl when a new Loader created . @param loaderId The loader ID @param bundle Arguments @return A new Loader instance
@Override
    public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
        switch (loaderId) {
            case ID_MOVIE_LOADER: {
                Uri uri;
                String sortOrder;
                int showMode = MoviesPreferences.getMoviesShowMode(this);
                if (showMode == MoviesPreferences.SHOW_MODE_MOST_POPULAR) {
                    uri = MoviesContract.MovieEntry.CONTENT_URI_MOST_POPULAR;
                    sortOrder = MoviesContract.MovieEntry.COLUMN_POPULARITY + " DESC";
                } else if (showMode == MoviesPreferences.SHOW_MODE_TOP_RATED) {
                    uri = MoviesContract.MovieEntry.CONTENT_URI_TOP_RATED;
                    sortOrder = MoviesContract.MovieEntry.COLUMN_VOTE_AVERAGE + " DESC";
                } else {
                    uri = MoviesContract.MovieEntry.CONTENT_URI_FAVORITE;
                    sortOrder = null;
                }
                return new CursorLoader(this,
                        uri,
                        MAIN_MOVIE_PROJECTION,
                        null,
                        null,
                        sortOrder);
            }
            default:
                throw new RuntimeException("Loader not implemented: " + loaderId);
        }
    }
@ Override public Loader < Cursor > onCreateLoader ( int loaderId , Bundle bundle ) { switch ( loaderId ) { case ID_MOVIE_LOADER : { Uri uri ; String sortOrder ; int showMode = MoviesPreferences . getMoviesShowMode ( this ) ; if ( showMode == MoviesPreferences . SHOW_MODE_MOST_POPULAR ) { uri = MoviesContract . MovieEntry . CONTENT_URI_MOST_POPULAR ; sortOrder = MoviesContract . MovieEntry . COLUMN_POPULARITY + " DESC" ; } else if ( showMode == MoviesPreferences . SHOW_MODE_TOP_RATED ) { uri = MoviesContract . MovieEntry . CONTENT_URI_TOP_RATED ; sortOrder = MoviesContract . MovieEntry . COLUMN_VOTE_AVERAGE + " DESC" ; } else { uri = MoviesContract . MovieEntry . CONTENT_URI_FAVORITE ; sortOrder = null ; } return new CursorLoader ( this , uri , MAIN_MOVIE_PROJECTION , null , null , sortOrder ) ; } default : throw new RuntimeException ( "Loader not implemented: " + loaderId ) ; } }
Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader created.
Called by the { @link android . support . v4 . app . LoaderManagerImpl } when a new Loader created .