com.facebook.widget
Class PickerFragment<T extends GraphObject>

java.lang.Object
  extended by android.support.v4.app.Fragment
      extended by com.facebook.widget.PickerFragment<T>
All Implemented Interfaces:
ComponentCallbacks, View.OnCreateContextMenuListener
Direct Known Subclasses:
FriendPickerFragment, PlacePickerFragment

public abstract class PickerFragment<T extends GraphObject>
extends Fragment

Provides functionality common to SDK UI elements that allow the user to pick one or more graph objects (e.g., places, friends) from a list of possibilities. The UI is exposed as a Fragment to allow to it to be included in an Activity along with other Fragments. The Fragments can be configured by passing parameters as part of their Intent bundle, or (for certain properties) by specifying attributes in their XML layout files.
PickerFragments support callbacks that will be called in the event of an error, when the underlying data has been changed, or when the set of selected graph objects changes.


Nested Class Summary
static interface PickerFragment.GraphObjectFilter<T>
          Callback interface that will be called to determine if a graph object should be displayed.
static interface PickerFragment.OnDataChangedListener
          Callback interface that will be called when the underlying data being displayed in the picker has been updated.
static interface PickerFragment.OnDoneButtonClickedListener
          Callback interface that will be called when the user clicks the Done button on the title bar.
static interface PickerFragment.OnErrorListener
          Callback interface that will be called when a network or other error is encountered while retrieving graph objects.
static interface PickerFragment.OnSelectionChangedListener
          Callback interface that will be called when the user selects or unselects graph objects in the picker.
 
Nested classes/interfaces inherited from class android.support.v4.app.Fragment
Fragment.InstantiationException, Fragment.SavedState
 
Field Summary
static String DONE_BUTTON_TEXT_BUNDLE_KEY
          The key for a String parameter in the fragment's Intent bundle to indicate the text to display in the Done btuton.
static String EXTRA_FIELDS_BUNDLE_KEY
          The key for a String parameter in the fragment's Intent bundle to indicate which extra fields beyond the default fields should be retrieved for any graph objects in the results.
static String SHOW_PICTURES_BUNDLE_KEY
          The key for a boolean parameter in the fragment's Intent bundle to indicate whether the picker should show pictures (if available) for the graph objects.
static String SHOW_TITLE_BAR_BUNDLE_KEY
          The key for a boolean parameter in the fragment's Intent bundle to indicate whether the picker should display a title bar with a Done button.
static String TITLE_TEXT_BUNDLE_KEY
          The key for a String parameter in the fragment's Intent bundle to indicate the text to display in the title bar.
 
Method Summary
 String getDoneButtonText()
          Gets the text to show in the Done button, if a title bar is to be shown.
 Set<String> getExtraFields()
          Gets the extra fields to request for the retrieved graph objects.
 PickerFragment.GraphObjectFilter<T> getFilter()
          Gets the current filter for this fragment, which will be called for each graph object returned from the service to determine if it should be displayed in the list.
 PickerFragment.OnDataChangedListener getOnDataChangedListener()
          Gets the current OnDataChangedListener for this fragment, which will be called whenever the underlying data being displaying in the picker has changed.
 PickerFragment.OnDoneButtonClickedListener getOnDoneButtonClickedListener()
          Gets the current OnDoneButtonClickedListener for this fragment, which will be called when the user clicks the Done button.
 PickerFragment.OnErrorListener getOnErrorListener()
          Gets the current OnErrorListener for this fragment, which will be called in the event of network or other errors encountered while populating the graph objects in the list.
 PickerFragment.OnSelectionChangedListener getOnSelectionChangedListener()
          Gets the current OnSelectionChangedListener for this fragment, which will be called whenever the user selects or unselects a graph object in the list.
 Session getSession()
          Gets the Session to use for any Facebook requests this fragment will make.
 boolean getShowPictures()
          Gets whether to display pictures, if available, for displayed graph objects.
 boolean getShowTitleBar()
          Gets whether to show a title bar with a Done button.
 String getTitleText()
          Gets the text to show in the title bar, if a title bar is to be shown.
 void loadData(boolean forceReload)
          Causes the picker to load data from the service and display it to the user.
 void onActivityCreated(Bundle savedInstanceState)
           
 void onCreate(Bundle savedInstanceState)
           
 View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
           
 void onDetach()
           
 void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
           
 void onSaveInstanceState(Bundle outState)
           
 void setArguments(Bundle args)
           
 void setDoneButtonText(String doneButtonText)
          Sets the text to show in the Done button, if a title bar is to be shown.
 void setExtraFields(Collection<String> fields)
          Sets the extra fields to request for the retrieved graph objects.
 void setFilter(PickerFragment.GraphObjectFilter<T> filter)
          Sets the current filter for this fragment, which will be called for each graph object returned from the service to determine if it should be displayed in the list.
 void setOnDataChangedListener(PickerFragment.OnDataChangedListener onDataChangedListener)
          Sets the current OnDataChangedListener for this fragment, which will be called whenever the underlying data being displaying in the picker has changed.
 void setOnDoneButtonClickedListener(PickerFragment.OnDoneButtonClickedListener onDoneButtonClickedListener)
          Sets the current OnDoneButtonClickedListener for this fragment, which will be called when the user clicks the Done button.
 void setOnErrorListener(PickerFragment.OnErrorListener onErrorListener)
          Sets the current OnErrorListener for this fragment, which will be called in the event of network or other errors encountered while populating the graph objects in the list.
 void setOnSelectionChangedListener(PickerFragment.OnSelectionChangedListener onSelectionChangedListener)
          Sets the current OnSelectionChangedListener for this fragment, which will be called whenever the user selects or unselects a graph object in the list.
 void setSession(Session session)
          Sets the Session to use for any Facebook requests this fragment will make.
 void setSettingsFromBundle(Bundle inState)
          Updates the properties of the PickerFragment based on the contents of the supplied Bundle; calling Activities may use this to pass additional configuration information to the PickerFragment beyond what is specified in its XML layout.
 void setShowPictures(boolean showPictures)
          Sets whether to display pictures, if available, for displayed graph objects.
 void setShowTitleBar(boolean showTitleBar)
          Sets whether to show a title bar with a Done button.
 void setTitleText(String titleText)
          Sets the text to show in the title bar, if a title bar is to be shown.
 
Methods inherited from class android.support.v4.app.Fragment
dump, equals, getActivity, getArguments, getChildFragmentManager, getFragmentManager, getId, getLayoutInflater, getLoaderManager, getParentFragment, getResources, getRetainInstance, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityResult, onAttach, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onHiddenChanged, onLowMemory, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPrepareOptionsMenu, onResume, onStart, onStop, onViewCreated, onViewStateRestored, registerForContextMenu, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setRetainInstance, setTargetFragment, setUserVisibleHint, startActivity, startActivityForResult, toString, unregisterForContextMenu
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SHOW_PICTURES_BUNDLE_KEY

public static final String SHOW_PICTURES_BUNDLE_KEY
The key for a boolean parameter in the fragment's Intent bundle to indicate whether the picker should show pictures (if available) for the graph objects.

See Also:
Constant Field Values

EXTRA_FIELDS_BUNDLE_KEY

public static final String EXTRA_FIELDS_BUNDLE_KEY
The key for a String parameter in the fragment's Intent bundle to indicate which extra fields beyond the default fields should be retrieved for any graph objects in the results.

See Also:
Constant Field Values

SHOW_TITLE_BAR_BUNDLE_KEY

public static final String SHOW_TITLE_BAR_BUNDLE_KEY
The key for a boolean parameter in the fragment's Intent bundle to indicate whether the picker should display a title bar with a Done button.

See Also:
Constant Field Values

TITLE_TEXT_BUNDLE_KEY

public static final String TITLE_TEXT_BUNDLE_KEY
The key for a String parameter in the fragment's Intent bundle to indicate the text to display in the title bar.

See Also:
Constant Field Values

DONE_BUTTON_TEXT_BUNDLE_KEY

public static final String DONE_BUTTON_TEXT_BUNDLE_KEY
The key for a String parameter in the fragment's Intent bundle to indicate the text to display in the Done btuton.

See Also:
Constant Field Values
Method Detail

onCreate

public void onCreate(Bundle savedInstanceState)
Overrides:
onCreate in class Fragment

onInflate

public void onInflate(Activity activity,
                      AttributeSet attrs,
                      Bundle savedInstanceState)
Overrides:
onInflate in class Fragment

onCreateView

public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState)
Overrides:
onCreateView in class Fragment

onActivityCreated

public void onActivityCreated(Bundle savedInstanceState)
Overrides:
onActivityCreated in class Fragment

onDetach

public void onDetach()
Overrides:
onDetach in class Fragment

onSaveInstanceState

public void onSaveInstanceState(Bundle outState)
Overrides:
onSaveInstanceState in class Fragment

setArguments

public void setArguments(Bundle args)
Overrides:
setArguments in class Fragment

getOnDataChangedListener

public PickerFragment.OnDataChangedListener getOnDataChangedListener()
Gets the current OnDataChangedListener for this fragment, which will be called whenever the underlying data being displaying in the picker has changed.

Returns:
the OnDataChangedListener, or null if there is none

setOnDataChangedListener

public void setOnDataChangedListener(PickerFragment.OnDataChangedListener onDataChangedListener)
Sets the current OnDataChangedListener for this fragment, which will be called whenever the underlying data being displaying in the picker has changed.

Parameters:
onDataChangedListener - the OnDataChangedListener, or null if there is none

getOnSelectionChangedListener

public PickerFragment.OnSelectionChangedListener getOnSelectionChangedListener()
Gets the current OnSelectionChangedListener for this fragment, which will be called whenever the user selects or unselects a graph object in the list.

Returns:
the OnSelectionChangedListener, or null if there is none

setOnSelectionChangedListener

public void setOnSelectionChangedListener(PickerFragment.OnSelectionChangedListener onSelectionChangedListener)
Sets the current OnSelectionChangedListener for this fragment, which will be called whenever the user selects or unselects a graph object in the list.

Parameters:
onSelectionChangedListener - the OnSelectionChangedListener, or null if there is none

getOnDoneButtonClickedListener

public PickerFragment.OnDoneButtonClickedListener getOnDoneButtonClickedListener()
Gets the current OnDoneButtonClickedListener for this fragment, which will be called when the user clicks the Done button.

Returns:
the OnDoneButtonClickedListener, or null if there is none

setOnDoneButtonClickedListener

public void setOnDoneButtonClickedListener(PickerFragment.OnDoneButtonClickedListener onDoneButtonClickedListener)
Sets the current OnDoneButtonClickedListener for this fragment, which will be called when the user clicks the Done button. This will only be possible if the title bar is being shown in this fragment.

Parameters:
onDoneButtonClickedListener - the OnDoneButtonClickedListener, or null if there is none

getOnErrorListener

public PickerFragment.OnErrorListener getOnErrorListener()
Gets the current OnErrorListener for this fragment, which will be called in the event of network or other errors encountered while populating the graph objects in the list.

Returns:
the OnErrorListener, or null if there is none

setOnErrorListener

public void setOnErrorListener(PickerFragment.OnErrorListener onErrorListener)
Sets the current OnErrorListener for this fragment, which will be called in the event of network or other errors encountered while populating the graph objects in the list.

Parameters:
onErrorListener - the OnErrorListener, or null if there is none

getFilter

public PickerFragment.GraphObjectFilter<T> getFilter()
Gets the current filter for this fragment, which will be called for each graph object returned from the service to determine if it should be displayed in the list. If no filter is specified, all retrieved graph objects will be displayed.

Returns:
the GraphObjectFilter, or null if there is none

setFilter

public void setFilter(PickerFragment.GraphObjectFilter<T> filter)
Sets the current filter for this fragment, which will be called for each graph object returned from the service to determine if it should be displayed in the list. If no filter is specified, all retrieved graph objects will be displayed.

Parameters:
filter - the GraphObjectFilter, or null if there is none

getSession

public Session getSession()
Gets the Session to use for any Facebook requests this fragment will make.

Returns:
the Session that will be used for any Facebook requests, or null if there is none

setSession

public void setSession(Session session)
Sets the Session to use for any Facebook requests this fragment will make. If the parameter is null, the fragment will use the current active session, if any.

Parameters:
session - the Session to use for Facebook requests, or null to use the active session

getShowPictures

public boolean getShowPictures()
Gets whether to display pictures, if available, for displayed graph objects.

Returns:
true if pictures should be displayed, false if not

setShowPictures

public void setShowPictures(boolean showPictures)
Sets whether to display pictures, if available, for displayed graph objects.

Parameters:
showPictures - true if pictures should be displayed, false if not

getExtraFields

public Set<String> getExtraFields()
Gets the extra fields to request for the retrieved graph objects.

Returns:
the extra fields to request

setExtraFields

public void setExtraFields(Collection<String> fields)
Sets the extra fields to request for the retrieved graph objects.

Parameters:
fields - the extra fields to request

setShowTitleBar

public void setShowTitleBar(boolean showTitleBar)
Sets whether to show a title bar with a Done button. This must be called prior to the Fragment going through its creation lifecycle to have an effect.

Parameters:
showTitleBar - true if a title bar should be displayed, false if not

getShowTitleBar

public boolean getShowTitleBar()
Gets whether to show a title bar with a Done button. The default is true.

Returns:
true if a title bar will be shown, false if not.

setTitleText

public void setTitleText(String titleText)
Sets the text to show in the title bar, if a title bar is to be shown. This must be called prior to the Fragment going through its creation lifecycle to have an effect, or the default will be used.

Parameters:
titleText - the text to show in the title bar

getTitleText

public String getTitleText()
Gets the text to show in the title bar, if a title bar is to be shown.

Returns:
the text to show in the title bar

setDoneButtonText

public void setDoneButtonText(String doneButtonText)
Sets the text to show in the Done button, if a title bar is to be shown. This must be called prior to the Fragment going through its creation lifecycle to have an effect, or the default will be used.

Parameters:
doneButtonText - the text to show in the Done button

getDoneButtonText

public String getDoneButtonText()
Gets the text to show in the Done button, if a title bar is to be shown.

Returns:
the text to show in the Done button

loadData

public void loadData(boolean forceReload)
Causes the picker to load data from the service and display it to the user.

Parameters:
forceReload - if true, data will be loaded even if there is already data being displayed (or loading); if false, data will not be re-loaded if it is already displayed (or loading)

setSettingsFromBundle

public void setSettingsFromBundle(Bundle inState)
Updates the properties of the PickerFragment based on the contents of the supplied Bundle; calling Activities may use this to pass additional configuration information to the PickerFragment beyond what is specified in its XML layout.

Parameters:
inState - a Bundle containing keys corresponding to properties of the PickerFragment