Disabling headers in BrowseFragment
<p>I need to disable headers in <strong>BrowseFragment</strong>, and add to the <strong>ArrayObjectAdapter</strong> card. When I do a <code>setHeadersState(HEADERS_DISABLED)</code> application crushes. If I run <code>setHeadersState(HEADERS_DISABLED)</code> method later, for example in <code>onLoadFinished</code>, the application does not crash, but the header bar immediately visible and then hidden, not every time an item is displayed in the adapter.</p>

<p><strong>MainFragment.class</strong></p>

<pre><code> public class MainFragment extends BrowseFragment implements LoaderManager.LoaderCallbacks&lt;List&lt;Module&gt;&gt; {
        private static final int MODULES_LOADER_ID = 100;
        private ArrayObjectAdapter mRowsAdapter;
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            setupUIElements();
            setupRowAdapter();
            setupListeners();
            getLoaderManager().initLoader(MODULES_LOADER_ID, null, this);
        }
            private void setupUIElements() {
            setTitle(getActivity().getString(R.string.app_name));
            setBadgeDrawable(getResources().getDrawable(R.drawable.title, getActivity().getTheme()));
            setHeadersTransitionOnBackEnabled(false);
            setBrandColor(getActivity().getResources().getColor(R.color.fastlane_background));
            setHeadersState(HEADERS_DISABLED);
        }
            private void setupRowAdapter() {
            mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
            setAdapter(mRowsAdapter);
        }
            private void setupListeners() {
            setOnItemViewSelectedListener(new ItemViewSelectedListener());
            setOnItemViewClickedListener(new ItemViewClickedListener());
        }
            private void loadModules(List&lt;Module&gt; modules) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new ModulesCardPresenter());
            for (Module module : modules) {
                listRowAdapter.add(module);
            }
            HeaderItem header = new HeaderItem(0, "Меню");
            mRowsAdapter.add(new ListRow(header, listRowAdapter));
        }
        @Override
        public Loader&lt;List&lt;Module&gt;&gt; onCreateLoader(int id, Bundle args) {
            switch (id) {
                case MODULES_LOADER_ID:
                    return new ModulesLoader(getActivity());
                default:
                    return null;
            }
        }
        @Override
        public void onLoadFinished(Loader&lt;List&lt;Module&gt;&gt; loader, List&lt;Module&gt; data) {
            switch (loader.getId()) {
                case MODULES_LOADER_ID:
                    loadModules(data);
                    break;
            }
        }
        @Override
        public void onLoaderReset(Loader&lt;List&lt;Module&gt;&gt; loader) {
        }
        static class ModulesLoader extends SimpleAsyncTaskLoader&lt;List&lt;Module&gt;&gt; {
            public ModulesLoader(Context context) {
                super(context);
            }
            @Override
            public List&lt;Module&gt; loadInBackground() {
                Call&lt;Modules&gt; mCall = ServiceHolder.getService()
                        .getModules(Constants.GET_MODULES_REQUEST);
                try {
                    return mCall.execute().body().getModules();
                } catch (Exception e) {
                    e.printStackTrace();
                    return Collections.EMPTY_LIST;
                }
            }
        }
        private final class ItemViewSelectedListener implements OnItemViewSelectedListener {
            @Override
            public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                                       RowPresenter.ViewHolder rowViewHolder, Row row) {
            }
        }
        private final class ItemViewClickedListener implements OnItemViewClickedListener {
            @Override
            public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                                      RowPresenter.ViewHolder rowViewHolder, Row row) {
                }
        }
</code></pre>

<p><strong>Log:</strong></p>

<pre><code>08-18 16:06:08.331 29647-29647/ E/AndroidRuntime: FATAL EXCEPTION: main
    Process: , PID: 29647
    **java.lang.RuntimeException: Unable to start activity ComponentInfo{.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Fragment.getView()' on a null object reference**
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    **Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Fragment.getView()' on a null object reference**
    at android.support.v17.leanback.app.BrowseFragment.onStart(BrowseFragment.java:1511)
    at android.app.Fragment.performStart(Fragment.java:2244)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1002)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
    at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:1958)
    at android.app.FragmentController.dispatchStart(FragmentController.java:163)
    at android.app.Activity.performStart(Activity.java:6274)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) &lt;/code&gt;
</code></pre>