Methods Summary |
---|
protected abstract void | bindChildView(android.view.View view, android.content.Context context, android.database.Cursor cursor, boolean isLastChild)Bind an existing view to the child data pointed to by cursor
|
protected abstract void | bindGroupView(android.view.View view, android.content.Context context, android.database.Cursor cursor, boolean isExpanded)Bind an existing view to the group data pointed to by cursor.
|
public void | changeCursor(android.database.Cursor cursor)
mGroupCursorHelper.changeCursor(cursor, true);
|
public java.lang.String | convertToString(android.database.Cursor cursor)
return cursor == null ? "" : cursor.toString();
|
synchronized void | deactivateChildrenCursorHelper(int groupPosition)Deactivates the Cursor and removes the helper from cache.
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
mChildrenCursorHelpers.remove(groupPosition);
cursorHelper.deactivate();
|
public android.database.Cursor | getChild(int groupPosition, int childPosition)
// Return this group's children Cursor pointing to the particular child
return getChildrenCursorHelper(groupPosition, true).moveTo(childPosition);
|
public long | getChildId(int groupPosition, int childPosition)
return getChildrenCursorHelper(groupPosition, true).getId(childPosition);
|
public android.view.View | getChildView(int groupPosition, int childPosition, boolean isLastChild, android.view.View convertView, android.view.ViewGroup parent)
MyCursorHelper cursorHelper = getChildrenCursorHelper(groupPosition, true);
Cursor cursor = cursorHelper.moveTo(childPosition);
if (cursor == null) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
View v;
if (convertView == null) {
v = newChildView(mContext, cursor, isLastChild, parent);
} else {
v = convertView;
}
bindChildView(v, mContext, cursor, isLastChild);
return v;
|
public int | getChildrenCount(int groupPosition)
MyCursorHelper helper = getChildrenCursorHelper(groupPosition, true);
return (mGroupCursorHelper.isValid() && helper != null) ? helper.getCount() : 0;
|
protected abstract android.database.Cursor | getChildrenCursor(android.database.Cursor groupCursor)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
{@link #setChildrenCursor(int, Cursor)}.
It is your responsibility to manage this Cursor through the Activity
lifecycle. It is a good idea to use {@link 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.
|
synchronized android.widget.CursorTreeAdapter$MyCursorHelper | getChildrenCursorHelper(int groupPosition, boolean requestCursor)Gets the cursor helper for the children in the given group.
MyCursorHelper cursorHelper = mChildrenCursorHelpers.get(groupPosition);
if (cursorHelper == null) {
if (mGroupCursorHelper.moveTo(groupPosition) == null) return null;
final Cursor cursor = getChildrenCursor(mGroupCursorHelper.getCursor());
cursorHelper = new MyCursorHelper(cursor);
mChildrenCursorHelpers.put(groupPosition, cursorHelper);
}
return cursorHelper;
|
public android.database.Cursor | getCursor()
return mGroupCursorHelper.getCursor();
|
public Filter | getFilter()
if (mCursorFilter == null) {
mCursorFilter = new CursorFilter(this);
}
return mCursorFilter;
|
public FilterQueryProvider | getFilterQueryProvider()
return mFilterQueryProvider;
|
public android.database.Cursor | getGroup(int groupPosition)
// Return the group Cursor pointing to the given group
return mGroupCursorHelper.moveTo(groupPosition);
|
public int | getGroupCount()
return mGroupCursorHelper.getCount();
|
public long | getGroupId(int groupPosition)
return mGroupCursorHelper.getId(groupPosition);
|
public android.view.View | getGroupView(int groupPosition, boolean isExpanded, android.view.View convertView, android.view.ViewGroup parent)
Cursor cursor = mGroupCursorHelper.moveTo(groupPosition);
if (cursor == null) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
View v;
if (convertView == null) {
v = newGroupView(mContext, cursor, isExpanded, parent);
} else {
v = convertView;
}
bindGroupView(v, mContext, cursor, isExpanded);
return v;
|
public boolean | hasStableIds()
return true;
|
private void | init(android.database.Cursor cursor, android.content.Context context, boolean autoRequery)
mContext = context;
mHandler = new Handler();
mAutoRequery = autoRequery;
mGroupCursorHelper = new MyCursorHelper(cursor);
mChildrenCursorHelpers = new SparseArray<MyCursorHelper>();
|
public boolean | isChildSelectable(int groupPosition, int childPosition)
return true;
|
protected abstract android.view.View | newChildView(android.content.Context context, android.database.Cursor cursor, boolean isLastChild, android.view.ViewGroup parent)Makes a new child view to hold the data pointed to by cursor.
|
protected abstract android.view.View | newGroupView(android.content.Context context, android.database.Cursor cursor, boolean isExpanded, android.view.ViewGroup parent)Makes a new group view to hold the group data pointed to by cursor.
|
public void | notifyDataSetChanged()
notifyDataSetChanged(true);
|
public void | notifyDataSetChanged(boolean releaseCursors)Notifies a data set change, but with the option of not releasing any
cached cursors.
if (releaseCursors) {
releaseCursorHelpers();
}
super.notifyDataSetChanged();
|
public void | notifyDataSetInvalidated()
releaseCursorHelpers();
super.notifyDataSetInvalidated();
|
public void | onGroupCollapsed(int groupPosition)
deactivateChildrenCursorHelper(groupPosition);
|
private synchronized void | releaseCursorHelpers()
for (int pos = mChildrenCursorHelpers.size() - 1; pos >= 0; pos--) {
mChildrenCursorHelpers.valueAt(pos).deactivate();
}
mChildrenCursorHelpers.clear();
|
public android.database.Cursor | runQueryOnBackgroundThread(java.lang.CharSequence constraint)
if (mFilterQueryProvider != null) {
return mFilterQueryProvider.runQuery(constraint);
}
return mGroupCursorHelper.getCursor();
|
public void | setChildrenCursor(int groupPosition, android.database.Cursor childrenCursor)Sets the children Cursor for a particular group.
This is useful when asynchronously querying to prevent blocking the UI.
/*
* Don't request a cursor from the subclass, instead we will be setting
* the cursor ourselves.
*/
MyCursorHelper childrenCursorHelper = getChildrenCursorHelper(groupPosition, false);
/*
* Don't release any cursor since we know exactly what data is changing
* (this cursor, which is still valid).
*/
childrenCursorHelper.changeCursor(childrenCursor, false);
|
public void | setFilterQueryProvider(FilterQueryProvider filterQueryProvider)
mFilterQueryProvider = filterQueryProvider;
|
public void | setGroupCursor(android.database.Cursor cursor)Sets the group Cursor.
mGroupCursorHelper.changeCursor(cursor, false);
|