コード例 #1
0
  private void clearResults() {
    if (adapter != null) {
      boolean wasSelection = !selectionStrategy.isEmpty();
      boolean wasData = !adapter.isEmpty();

      loadingStrategy.clearResults();
      selectionStrategy.clear();
      adapter.notifyDataSetChanged();

      // Tell anyone who cares the data and selection has changed, if they have.
      if (wasData && onDataChangedListener != null) {
        onDataChangedListener.onDataChanged(PickerFragment.this);
      }
      if (wasSelection && onSelectionChangedListener != null) {
        onSelectionChangedListener.onSelectionChanged(PickerFragment.this);
      }
    }
  }
コード例 #2
0
  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    saveSettingsToBundle(outState);
    selectionStrategy.saveSelectionToBundle(outState, SELECTION_BUNDLE_KEY);
    if (activityCircle != null) {
      outState.putBoolean(ACTIVITY_CIRCLE_SHOW_KEY, activityCircle.getVisibility() == View.VISIBLE);
    }
  }
コード例 #3
0
  private void onListItemClick(ListView listView, View v, int position) {
    @SuppressWarnings("unchecked")
    T graphObject = (T) listView.getItemAtPosition(position);
    String id = adapter.getIdOfGraphObject(graphObject);
    selectionStrategy.toggleSelection(id);
    adapter.notifyDataSetChanged();

    if (onSelectionChangedListener != null) {
      onSelectionChangedListener.onSelectionChanged(PickerFragment.this);
    }
  }
コード例 #4
0
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    sessionTracker =
        new SessionTracker(
            getActivity(),
            new Session.StatusCallback() {
              @Override
              public void call(Session session, SessionState state, Exception exception) {
                if (!session.isOpened()) {
                  // When a session is closed, we want to clear out our data so it is not visible to
                  // subsequent users
                  clearResults();
                }
              }
            });

    setSettingsFromBundle(savedInstanceState);

    loadingStrategy = createLoadingStrategy();
    loadingStrategy.attach(adapter);

    selectionStrategy = createSelectionStrategy();
    selectionStrategy.readSelectionFromBundle(savedInstanceState, SELECTION_BUNDLE_KEY);

    // Should we display a title bar? (We need to do this after we've retrieved our bundle
    // settings.)
    if (showTitleBar) {
      inflateTitleBar((ViewGroup) getView());
    }

    if (activityCircle != null && savedInstanceState != null) {
      boolean shown = savedInstanceState.getBoolean(ACTIVITY_CIRCLE_SHOW_KEY, false);
      if (shown) {
        displayActivityCircle();
      } else {
        // Should be hidden already, but just to be sure.
        hideActivityCircle();
      }
    }
  }
コード例 #5
0
 List<T> getSelectedGraphObjects() {
   return adapter.getGraphObjectsById(selectionStrategy.getSelectedIds());
 }