Summary: Inherited Constants | Inherited Fields | Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]

# FragmentGridPagerAdapter

`public abstract class FragmentGridPagerAdapter`
`` `extends GridPagerAdapter` ``

java.lang.Object
↳ | android.support.wearable.view.GridPagerAdapter
| ↳ | android.support.wearable.view.FragmentGridPagerAdapter

An implementation of GridPagerAdapter which represents each page as a `Fragment`.

A minimal implementation needs only the abstract methods: `getRowCount()`, `getColumnCount(int)`, `getFragment(int, int)`.

If any changes are made to the data, `notifyDataSetChanged()` must be called to notify the adapter of the change, so it can be reflected in the View.

If pages the data at be inserted or removed, performance can be improved by implementing `getFragmentId(int, int)` to to provide a stable ID for each item, based on the content.

## Summary

### Inherited constants
From class `android.support.wearable.view.GridPagerAdapter`
`int` | `OPTION_DISABLE_PARALLAX` Disables zooming and parallax scrolling of the background.
`int` | `PAGE_DEFAULT_OPTIONS` Default background options.

### Inherited fields
From class `android.support.wearable.view.GridPagerAdapter`
`public static final Drawable` | `BACKGROUND_NONE` This value indicates that no background should drawn.
`public static final Point` | `POSITION_NONE`
`public static final Point` | `POSITION_UNCHANGED`

### Public constructors
`FragmentGridPagerAdapter(FragmentManager fm)`

### Public methods
`void` | `destroyItem(ViewGroup container, int row, int column, Object object)` Removes a page for the given position.
`Fragment` | `findExistingFragment(int row, int column)`
`void` | `finishUpdate(ViewGroup container)` Called when the a change in the shown pages has been completed.
`Drawable` | `getBackgroundForPage(int row, int column)` Provides content to be displayed as the background for a specific page.
`abstract Fragment` | `getFragment(int row, int column)` Returns the `Fragment` at the specified row number and column number.
`final Drawable` | `getFragmentBackground(int row, int column)` Returns a background for Fragments implementing `GridPageOptions`.
`long` | `getFragmentId(int row, int column)` Returns a unique identifier for the `Fragment` at the given row/column position.
`Fragment` | `instantiateItem(ViewGroup container, int row, int column)` Creates the page for the given position.
`boolean` | `isViewFromObject(View view, Object object)` Determines whether a page View is associated with a specific key object as returned by `instantiateItem(ViewGroup, int, int)`.

### Protected methods
`void` | `applyItemPosition(Object object, Point position)` Called after `getItemPosition(Object)` to allow superclasses to update their internal bookkeeping if a subclass has overridden `getItemPosition(Object)`.
`void` | `removeFragment(Fragment fragment, FragmentTransaction transaction)`
`void` | `restoreFragment(Fragment fragment, FragmentTransaction transaction)`

### Inherited methods
From class `android.support.wearable.view.GridPagerAdapter`
`void` | `applyItemPosition(Object object, Point position)` Called after `getItemPosition(Object)` to allow superclasses to update their internal bookkeeping if a subclass has overridden `getItemPosition(Object)`.
`abstract void` | `destroyItem(ViewGroup container, int row, int column, Object object)` Removes a page for the given position.
`void` | `finishUpdate(ViewGroup container)` Called when the a change in the shown pages has been completed.
`Drawable` | `getBackgroundForPage(int row, int column)` Provides content to be displayed as background for a specific page.
`Drawable` | `getBackgroundForRow(int row)` Provides content to be displayed as the default background for all pages on the given row.
`abstract int` | `getColumnCount(int row)` Returns the maximum number of columns for each row.
`int` | `getCurrentColumnForRow(int row, int currentColumn)` Returns the column to arrive at when navigating vertically to the specified row.
`Point` | `getItemPosition(Object object)` Called when the host view is attempting to determine if an item's position has changed.
`int` | `getOptionsForPage(int row, int column)` Provides a set of features to apply to a page background.
`abstract int` | `getRowCount()` Returns the number of rows available.
`abstract Object` | `instantiateItem(ViewGroup container, int row, int column)` Creates the page for the given position.
`abstract boolean` | `isViewFromObject(View view, Object object)` Determines whether a page View is associated with a specific key object as returned by `instantiateItem(ViewGroup, int, int)`.
`void` | `notifyDataSetChanged()` This method should be called by the application if the data backing this adapter has changed and associated views should update.
`void` | `notifyPageBackgroundChanged(int row, int column)` This method should be called if the value returned by `getBackgroundForPage(int, int)` or options returned by `getOptionsForPage(int, int)` change.
`void` | `notifyRowBackgroundChanged(int row)` This method should be called if the value returned by `getBackgroundForRow(int)` changes.
`void` | `registerDataSetObserver(DataSetObserver observer)` Register an observer to receive callbacks related to the adapter's data changing.
`void` | `restoreState(Parcelable savedState, ClassLoader classLoader)` Restores the previously saved state of this adapter.
`Parcelable` | `saveState()` Saves the current state of this adapter.
`void` | `setCurrentColumnForRow(int row, int currentColumn)` Called to inform the adapter of which column is now current for the given row.
`void` | `startUpdate(ViewGroup container)` Called when a change in the shown pages is going to start being made.
`void` | `unregisterDataSetObserver(DataSetObserver observer)` Unregister an observer from callbacks related to the adapter's data changing.
From class `java.lang.Object`
`Object` | `clone()`
`boolean` | `equals(Object arg0)`
`void` | `finalize()`
`final Class<?>` | `getClass()`
`int` | `hashCode()`
`final void` | `notify()`
`final void` | `notifyAll()`
`String` | `toString()`
`final void` | `wait(long arg0, int arg1)`
`final void` | `wait(long arg0)`
`final void` | `wait()`

## Public constructors

### FragmentGridPagerAdapter

    FragmentGridPagerAdapter (FragmentManager fm)

Parameters
`fm` | `FragmentManager`

## Public methods

### destroyItem

    void destroyItem (ViewGroup container,
                    int row,
                    int column,
                    Object object)

Removes a page for the given position. The adapter is responsible for removing the view from its container, although it only must ensure this is done by the time it returns from `finishUpdate(ViewGroup)`.

Parameters
`container` | `ViewGroup`: The containing View from which the page will be removed.
`row` | `int`: the row to be destroyed
`column` | `int`: the column within the row to be destroyed
`object` | `Object`: The same object that was returned by `instantiateItem(ViewGroup, int, int)`.

### findExistingFragment

    Fragment findExistingFragment (int row,
                    int column)

Parameters
`row` | `int`
`column` | `int`

Returns
`Fragment` |

### finishUpdate

    void finishUpdate (ViewGroup container)

Called when the a change in the shown pages has been completed. At this point you must ensure that all of the pages have actually been added or removed from the container as appropriate.

Parameters
`container` | `ViewGroup`: The containing View which is displaying this adapter's page views

### getBackgroundForPage

    Drawable getBackgroundForPage (int row,
                    int column)

Provides content to be displayed as the background for a specific page.

The return value `BACKGROUND_NONE` indicates that there is no page-specific background. and the row background should be used (if any).

This implementation simply returns the result of `getFragmentBackground(int, int)`.

Parameters
`row` | `int`: the row of the page
`column` | `int`: the column of the page

Returns
`Drawable` | the background for the given page or `BACKGROUND_NONE`

### getFragment

    Fragment getFragment (int row,
                    int column)

Returns the `Fragment` at the specified row number and column number.

Fragment instances MAY be stored and reused ONLY if no structural changes are made to the data set or if `getFragmentId(int, int)` is overridden to provide a stable identifier for each the item at each position, otherwise results are undefined.

Parameters
`row` | `int`: the row of the position
`column` | `int`: the column of the position

Returns
`Fragment` |

### getFragmentBackground

    Drawable getFragmentBackground (int row,
                    int column)

Returns a background for Fragments implementing `GridPageOptions`.

Parameters
`row` | `int`: the row of the fragment
`column` | `int`: the column of the fragment

Returns
`Drawable` | the background drawable or `BACKGROUND_NONE` if the fragment does not implement `GridPageOptions`

### getFragmentId

    long getFragmentId (int row,
                    int column)

Returns a unique identifier for the `Fragment` at the given row/column position.

The default implementation returns a fixed number based on the position. Subclasses should override this method if the positions of items can change.

Parameters
`row` | `int`: the row that this item is at
`column` | `int`: the column within this row that the item is at

Returns
`long` | Unique identifier for the item at position

### instantiateItem

    Fragment instantiateItem (ViewGroup container,
                    int row,
                    int column)

Creates the page for the given position. The adapter is responsible for adding the view to the container given here, although it only must ensure this is done by the time it returns from `finishUpdate(ViewGroup)`

Parameters
`container` | `ViewGroup`: containing View in which the page will be shown
`row` | `int`: the row to be instantiated
`column` | `int`: the column within the row to be instantiated

Returns
`Fragment` | a an object representing the new page

### isViewFromObject

    boolean isViewFromObject (View view,
                    Object object)

Determines whether a page View is associated with a specific key object as returned by `instantiateItem(ViewGroup, int, int)`. This method is required for a PagerAdapter to function properly.

Parameters
`view` | `View`: Page View to check for association with `object`
`object` | `Object`: Object to check for association with `view`

Returns
`boolean` | true if `view` is associated with the key object `object`

## Protected methods

### applyItemPosition

    void applyItemPosition (Object object,
                    Point position)

Called after `getItemPosition(Object)` to allow superclasses to update their internal bookkeeping if a subclass has overridden `getItemPosition(Object)`.

Parameters
`object` | `Object`: Object representing the item passed to `getItemPosition(Object)`.
`position` | `Point`: position which was returned from `getItemPosition(Object)`.

### removeFragment

    void removeFragment (Fragment fragment,
                    FragmentTransaction transaction)

Parameters
`fragment` | `Fragment`
`transaction` | `FragmentTransaction`

### restoreFragment

    void restoreFragment (Fragment fragment,
                    FragmentTransaction transaction)

Parameters
`fragment` | `Fragment`
`transaction` | `FragmentTransaction`

- ## Interfaces

  - ActionChooserView.ActionChooserListener
  - DelayedConfirmationView.DelayedConfirmationListener
  - GridPageOptions
  - GridPageOptions.BackgroundListener
  - GridViewPager.OnAdapterChangeListener
  - GridViewPager.OnPageChangeListener
  - WatchViewStub.OnLayoutInflatedListener
  - WearableListView.ClickListener
  - WearableListView.OnCenterProximityListener
  - WearableListView.OnCentralPositionChangedListener
  - WearableListView.OnScrollListener

- ## Classes

  - ActionChooserView
  - ActionLabel
  - ActionPage
  - BoxInsetLayout
  - BoxInsetLayout.LayoutParams
  - CardFragment
  - CardFrame
  - CardScrollView
  - CircledImageView
  - CircularButton
  - CrossfadeDrawable
  - DelayedConfirmationView
  - DismissOverlayView
  - DotsPageIndicator
  - FragmentGridPagerAdapter
  - GridPagerAdapter
  - GridViewPager
  - GridViewPager.LayoutParams
  - ProgressSpinner
  - SimpleAnimatorListener
  - WatchViewStub
  - WearableFrameLayout
  - WearableFrameLayout.LayoutParams
  - WearableListView
  - WearableListView.Adapter
  - WearableListView.ViewHolder