CursorTreeAdapter
abstract class CursorTreeAdapter : BaseExpandableListAdapter, Filterable
| kotlin.Any | ||
| ↳ | android.widget.BaseExpandableListAdapter | |
| ↳ | android.widget.CursorTreeAdapter | |
An adapter that exposes data from a series of Cursors to an ExpandableListView widget. The top-level Cursor (that is given in the constructor) exposes the groups, while subsequent Cursors returned from getChildrenCursor(android.database.Cursor) expose children within a particular group. The Cursors must include a column named "_id" or this class will not work.
Summary
| Public constructors | |
|---|---|
CursorTreeAdapter(cursor: Cursor!, context: Context!)Constructor. |
|
CursorTreeAdapter(cursor: Cursor!, context: Context!, autoRequery: Boolean)Constructor. |
|
| Public methods | |
|---|---|
| open Unit |
changeCursor(cursor: Cursor!) |
| open String! |
convertToString(cursor: Cursor!) |
| open Cursor! |
Gets the data associated with the given child within the given group. |
| open Long |
getChildId(groupPosition: Int, childPosition: Int)Gets the ID for the given child within the given group. |
| open View! |
getChildView(groupPosition: Int, childPosition: Int, isLastChild: Boolean, convertView: View!, parent: ViewGroup!)Gets a View that displays the data for the given child within the given group. |
| open Int |
getChildrenCount(groupPosition: Int)Gets the number of children in a specified group. |
| open Cursor! | |
| open Filter! |
Returns a filter that can be used to constrain data with a filtering pattern. |
| open FilterQueryProvider! | |
| open Cursor! |
Gets the data associated with the given group. |
| open Int |
Gets the number of groups. |
| open Long |
getGroupId(groupPosition: Int)Gets the ID for the group at the given position. |
| open View! |
getGroupView(groupPosition: Int, isExpanded: Boolean, convertView: View!, parent: ViewGroup!)Gets a View that displays the given group. |
| open Boolean |
Indicates whether the child and group IDs are stable across changes to the underlying data. |
| open Boolean |
isChildSelectable(groupPosition: Int, childPosition: Int)Whether the child at the specified position is selectable. |
| open Unit | |
| open Unit |
notifyDataSetChanged(releaseCursors: Boolean)Notifies a data set change, but with the option of not releasing any cached cursors. |
| open Unit | |
| open Unit |
onGroupCollapsed(groupPosition: Int)Called when a group is collapsed. |
| open Cursor! |
runQueryOnBackgroundThread(constraint: CharSequence!) |
| open Unit |
setChildrenCursor(groupPosition: Int, childrenCursor: Cursor!)Sets the children Cursor for a particular group. |
| open Unit |
setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!) |
| open Unit |
setGroupCursor(cursor: Cursor!)Sets the group Cursor. |
| Protected methods | |
|---|---|
| abstract Unit |
bindChildView(view: View!, context: Context!, cursor: Cursor!, isLastChild: Boolean)Bind an existing view to the child data pointed to by cursor |
| abstract Unit |
bindGroupView(view: View!, context: Context!, cursor: Cursor!, isExpanded: Boolean)Bind an existing view to the group data pointed to by cursor. |
| abstract Cursor! |
getChildrenCursor(groupCursor: Cursor!)Gets the Cursor for the children at the given group. |
| abstract View! |
newChildView(context: Context!, cursor: Cursor!, isLastChild: Boolean, parent: ViewGroup!)Makes a new child view to hold the data pointed to by cursor. |
| abstract View! |
newGroupView(context: Context!, cursor: Cursor!, isExpanded: Boolean, parent: ViewGroup!)Makes a new group view to hold the group data pointed to by cursor. |
| Inherited functions | |
|---|---|
Public constructors
CursorTreeAdapter
CursorTreeAdapter(
cursor: Cursor!,
context: Context!)
Constructor. The adapter will call Cursor.requery() on the cursor whenever it changes so that the most recent data is always displayed.
| Parameters | |
|---|---|
cursor |
Cursor!: The cursor from which to get the data for the groups. |
CursorTreeAdapter
CursorTreeAdapter(
cursor: Cursor!,
context: Context!,
autoRequery: Boolean)
Constructor.
| Parameters | |
|---|---|
cursor |
Cursor!: The cursor from which to get the data for the groups. |
context |
Context!: The context |
autoRequery |
Boolean: If true the adapter will call Cursor.requery() on the cursor whenever it changes so the most recent data is always displayed. |
Public methods
getChild
open fun getChild(
groupPosition: Int,
childPosition: Int
): Cursor!
Gets the data associated with the given child within the given group.
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group that the child resides in |
childPosition |
Int: the position of the child with respect to other children in the group |
| Return | |
|---|---|
Cursor! |
the data of the child |
getChildId
open fun getChildId(
groupPosition: Int,
childPosition: Int
): Long
Gets the ID for the given child within the given group. This ID must be unique across all children within the group. The combined ID (see getCombinedChildId(long,long)) must be unique across ALL items (groups and all children).
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group that contains the child |
childPosition |
Int: the position of the child within the group for which the ID is wanted |
| Return | |
|---|---|
Long |
the ID associated with the child |
getChildView
open fun getChildView(
groupPosition: Int,
childPosition: Int,
isLastChild: Boolean,
convertView: View!,
parent: ViewGroup!
): View!
Gets a View that displays the data for the given child within the given group.
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group that contains the child |
childPosition |
Int: the position of the child (for which the View is returned) within the group |
isLastChild |
Boolean: Whether the child is the last child within the group |
convertView |
View!: the old view to reuse, if possible. You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. It is not guaranteed that the convertView will have been previously created by getChildView(int,int,boolean,android.view.View,android.view.ViewGroup). |
parent |
ViewGroup!: the parent that this view will eventually be attached to |
| Return | |
|---|---|
View! |
the View corresponding to the child at the specified position |
getChildrenCount
open fun getChildrenCount(groupPosition: Int): Int
Gets the number of children in a specified group.
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group for which the children count should be returned |
| Return | |
|---|---|
Int |
the children count in the specified group |
getFilter
open fun getFilter(): Filter!
Returns a filter that can be used to constrain data with a filtering pattern.
This method is usually implemented by android.widget.Adapter classes.
| Return | |
|---|---|
Filter! |
a filter used to constrain data |
getGroup
open fun getGroup(groupPosition: Int): Cursor!
Gets the data associated with the given group.
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group |
| Return | |
|---|---|
Cursor! |
the data child for the specified group |
getGroupCount
open fun getGroupCount(): Int
Gets the number of groups.
| Return | |
|---|---|
Int |
the number of groups |
getGroupId
open fun getGroupId(groupPosition: Int): Long
Gets the ID for the group at the given position. This group ID must be unique across groups. The combined ID (see getCombinedGroupId(long)) must be unique across ALL items (groups and all children).
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group for which the ID is wanted |
| Return | |
|---|---|
Long |
the ID associated with the group |
getGroupView
open fun getGroupView(
groupPosition: Int,
isExpanded: Boolean,
convertView: View!,
parent: ViewGroup!
): View!
Gets a View that displays the given group. This View is only for the group--the Views for the group's children will be fetched using getChildView(int,int,boolean,android.view.View,android.view.ViewGroup).
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group for which the View is returned |
isExpanded |
Boolean: whether the group is expanded or collapsed |
convertView |
View!: the old view to reuse, if possible. You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. It is not guaranteed that the convertView will have been previously created by getGroupView(int,boolean,android.view.View,android.view.ViewGroup). |
parent |
ViewGroup!: the parent that this view will eventually be attached to |
| Return | |
|---|---|
View! |
the View corresponding to the group at the specified position |
hasStableIds
open fun hasStableIds(): Boolean
Indicates whether the child and group IDs are stable across changes to the underlying data.
| Return | |
|---|---|
Boolean |
whether or not the same ID always refers to the same object |
isChildSelectable
open fun isChildSelectable(
groupPosition: Int,
childPosition: Int
): Boolean
Whether the child at the specified position is selectable.
| Parameters | |
|---|---|
groupPosition |
Int: the position of the group that contains the child |
childPosition |
Int: the position of the child within the group |
| Return | |
|---|---|
Boolean |
whether the child is selectable. |
notifyDataSetChanged
open fun notifyDataSetChanged(releaseCursors: Boolean): Unit
Notifies a data set change, but with the option of not releasing any cached cursors.
| Parameters | |
|---|---|
releaseCursors |
Boolean: Whether to release and deactivate any cached cursors. |
onGroupCollapsed
open fun onGroupCollapsed(groupPosition: Int): Unit
Called when a group is collapsed.
| Parameters | |
|---|---|
groupPosition |
Int: The group being collapsed. |
runQueryOnBackgroundThread
open fun runQueryOnBackgroundThread(constraint: CharSequence!): Cursor!
setChildrenCursor
open fun setChildrenCursor(
groupPosition: Int,
childrenCursor: Cursor!
): Unit
Sets the children Cursor for a particular group. If there is an existing cursor it will be closed.
This is useful when asynchronously querying to prevent blocking the UI.
| Parameters | |
|---|---|
groupPosition |
Int: The group whose children are being set via this Cursor. |
childrenCursor |
Cursor!: The Cursor that contains the children of the group. |
setFilterQueryProvider
open fun setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!): Unit
setGroupCursor
open fun setGroupCursor(cursor: Cursor!): Unit
Sets the group Cursor.
| Parameters | |
|---|---|
cursor |
Cursor!: The Cursor to set for the group. If there is an existing cursor it will be closed. |
Protected methods
bindChildView
protected abstract fun bindChildView(
view: View!,
context: Context!,
cursor: Cursor!,
isLastChild: Boolean
): Unit
Bind an existing view to the child data pointed to by cursor
| Parameters | |
|---|---|
view |
View!: Existing view, returned earlier by newChildView |
context |
Context!: Interface to application's global information |
cursor |
Cursor!: The cursor from which to get the data. The cursor is already moved to the correct position. |
isLastChild |
Boolean: Whether the child is the last child within its group. |
bindGroupView
protected abstract fun bindGroupView(
view: View!,
context: Context!,
cursor: Cursor!,
isExpanded: Boolean
): Unit
Bind an existing view to the group data pointed to by cursor.
| Parameters | |
|---|---|
view |
View!: Existing view, returned earlier by newGroupView. |
context |
Context!: Interface to application's global information |
cursor |
Cursor!: The cursor from which to get the data. The cursor is already moved to the correct position. |
isExpanded |
Boolean: Whether the group is expanded. |
getChildrenCursor
protected abstract fun getChildrenCursor(groupCursor: Cursor!): Cursor!
Gets the Cursor for the children at the given group. Subclasses must implement this method to return the children data for a particular group.
If you want to asynchronously query a provider to prevent blocking the UI, it is possible to return null and at a later time call setChildrenCursor(int,android.database.Cursor).
It is your responsibility to manage this Cursor through the Activity lifecycle. It is a good idea to use Activity.managedQuery which will handle this for you. In some situations, the adapter will deactivate the Cursor on its own, but this will not always be the case, so please ensure the Cursor is properly managed.
| Parameters | |
|---|---|
groupCursor |
Cursor!: The cursor pointing to the group whose children cursor should be returned |
| Return | |
|---|---|
Cursor! |
The cursor for the children of a particular group, or null. |
newChildView
protected abstract fun newChildView(
context: Context!,
cursor: Cursor!,
isLastChild: Boolean,
parent: ViewGroup!
): View!
Makes a new child view to hold the data pointed to by cursor.
| Parameters | |
|---|---|
context |
Context!: Interface to application's global information |
cursor |
Cursor!: The cursor from which to get the data. The cursor is already moved to the correct position. |
isLastChild |
Boolean: Whether the child is the last child within its group. |
parent |
ViewGroup!: The parent to which the new view is attached to |
| Return | |
|---|---|
View! |
the newly created view. |
newGroupView
protected abstract fun newGroupView(
context: Context!,
cursor: Cursor!,
isExpanded: Boolean,
parent: ViewGroup!
): View!
Makes a new group view to hold the group data pointed to by cursor.
| Parameters | |
|---|---|
context |
Context!: Interface to application's global information |
cursor |
Cursor!: The group cursor from which to get the data. The cursor is already moved to the correct position. |
isExpanded |
Boolean: Whether the group is expanded. |
parent |
ViewGroup!: The parent to which the new view is attached to |
| Return | |
|---|---|
View! |
The newly created view. |