public void attach(GraphObjectAdapter<T> adapter) {
      loader =
          (GraphObjectPagingLoader<T>)
              getLoaderManager()
                  .initLoader(
                      0,
                      null,
                      new LoaderManager.LoaderCallbacks<SimpleGraphObjectCursor<T>>() {
                        @Override
                        public Loader<SimpleGraphObjectCursor<T>> onCreateLoader(
                            int id, Bundle args) {
                          return LoadingStrategy.this.onCreateLoader();
                        }

                        @Override
                        public void onLoadFinished(
                            Loader<SimpleGraphObjectCursor<T>> loader,
                            SimpleGraphObjectCursor<T> data) {
                          if (loader != LoadingStrategy.this.loader) {
                            throw new FacebookException("Received callback for unknown loader.");
                          }
                          LoadingStrategy.this.onLoadFinished(
                              (GraphObjectPagingLoader<T>) loader, data);
                        }

                        @Override
                        public void onLoaderReset(Loader<SimpleGraphObjectCursor<T>> loader) {
                          if (loader != LoadingStrategy.this.loader) {
                            throw new FacebookException("Received callback for unknown loader.");
                          }
                          LoadingStrategy.this.onLoadReset((GraphObjectPagingLoader<T>) loader);
                        }
                      });

      loader.setOnErrorListener(
          new GraphObjectPagingLoader.OnErrorListener() {
            @Override
            public void onError(FacebookException error, GraphObjectPagingLoader<?> loader) {
              hideActivityCircle();
              if (onErrorListener != null) {
                onErrorListener.onError(PickerFragment.this, error);
              }
            }
          });

      this.adapter = adapter;
      // Tell the adapter about any data we might already have.
      this.adapter.changeCursor(loader.getCursor());
      this.adapter.setOnErrorListener(
          new GraphObjectAdapter.OnErrorListener() {
            @Override
            public void onError(GraphObjectAdapter<?> adapter, FacebookException error) {
              if (onErrorListener != null) {
                onErrorListener.onError(PickerFragment.this, error);
              }
            }
          });
    }
    public void detach() {
      adapter.setDataNeededListener(null);
      adapter.setOnErrorListener(null);
      loader.setOnErrorListener(null);

      loader = null;
      adapter = null;
    }
 public boolean isDataPresentOrLoading() {
   return !adapter.isEmpty() || loader.isLoading();
 }
 public void startLoading(Request request) {
   if (loader != null) {
     loader.startLoading(request, canSkipRoundTripIfCached());
     onStartLoading(loader, request);
   }
 }
 public void clearResults() {
   if (loader != null) {
     loader.clearResults();
   }
 }