Added in API level 11

RemoteViewsFactory


interface RemoteViewsFactory
android.widget.RemoteViewsService.RemoteViewsFactory

An interface for an adapter between a remote collection view (ListView, GridView, etc) and the underlying data for that view. The implementor is responsible for making a RemoteView for each item in the data set. This interface is a thin wrapper around Adapter.

Summary

Public methods
abstract Int

See Adapter.getCount()

abstract Long
getItemId(position: Int)

See Adapter.getItemId(int).

abstract RemoteViews!

This allows for the use of a custom loading view which appears between the time that getViewAt(int) is called and returns.

abstract RemoteViews!
getViewAt(position: Int)

See Adapter.getView(int, android.view.View, android.view.ViewGroup).

abstract Int

See Adapter.getViewTypeCount().

abstract Boolean

See Adapter.hasStableIds().

abstract Unit

Called when your factory is first constructed.

abstract Unit

Called when notifyDataSetChanged() is triggered on the remote adapter.

abstract Unit

Called when the last RemoteViewsAdapter that is associated with this factory is unbound.

Public methods

getCount

Added in API level 11
abstract fun getCount(): Int

See Adapter.getCount()

Return
Int Count of items.

getItemId

Added in API level 11
abstract fun getItemId(position: Int): Long

See Adapter.getItemId(int).

Parameters
position Int: The position of the item within the data set whose row id we want.
Return
Long The id of the item at the specified position.

getLoadingView

Added in API level 11
abstract fun getLoadingView(): RemoteViews!

This allows for the use of a custom loading view which appears between the time that getViewAt(int) is called and returns. If null is returned, a default loading view will be used.

Return
RemoteViews! The RemoteViews representing the desired loading view.

getViewAt

Added in API level 11
abstract fun getViewAt(position: Int): RemoteViews!

See Adapter.getView(int, android.view.View, android.view.ViewGroup). Note: expensive tasks can be safely performed synchronously within this method, and a loading view will be displayed in the interim. See getLoadingView().

Parameters
position Int: The position of the item within the Factory's data set of the item whose view we want.
Return
RemoteViews! A RemoteViews object corresponding to the data at the specified position.

getViewTypeCount

Added in API level 11
abstract fun getViewTypeCount(): Int

See Adapter.getViewTypeCount().

Return
Int The number of types of Views that will be returned by this factory.

hasStableIds

Added in API level 11
abstract fun hasStableIds(): Boolean

See Adapter.hasStableIds().

Return
Boolean True if the same id always refers to the same object.

onCreate

Added in API level 11
abstract fun onCreate(): Unit

Called when your factory is first constructed. The same factory may be shared across multiple RemoteViewAdapters depending on the intent passed.

onDataSetChanged

Added in API level 11
abstract fun onDataSetChanged(): Unit

Called when notifyDataSetChanged() is triggered on the remote adapter. This allows a RemoteViewsFactory to respond to data changes by updating any internal references. Note: expensive tasks can be safely performed synchronously within this method. In the interim, the old data will be displayed within the widget.

onDestroy

Added in API level 11
abstract fun onDestroy(): Unit

Called when the last RemoteViewsAdapter that is associated with this factory is unbound.