use of android.widget.ExpandableListAdapter in project HoloEverywhere by Prototik.
the class ExpandableListConnector method findGroupPosition.
int findGroupPosition(long groupIdToMatch, int seedGroupPosition) {
int count = mExpandableListAdapter.getGroupCount();
if (count == 0) {
return AdapterView.INVALID_POSITION;
}
if (groupIdToMatch == AdapterView.INVALID_ROW_ID) {
return AdapterView.INVALID_POSITION;
}
seedGroupPosition = Math.max(0, seedGroupPosition);
seedGroupPosition = Math.min(count - 1, seedGroupPosition);
long endTime = SystemClock.uptimeMillis() + AdapterView.SYNC_MAX_DURATION_MILLIS;
long rowId;
int first = seedGroupPosition;
int last = seedGroupPosition;
boolean next = false;
boolean hitFirst;
boolean hitLast;
ExpandableListAdapter adapter = getAdapter();
if (adapter == null) {
return AdapterView.INVALID_POSITION;
}
while (SystemClock.uptimeMillis() <= endTime) {
rowId = adapter.getGroupId(seedGroupPosition);
if (rowId == groupIdToMatch) {
return seedGroupPosition;
}
hitLast = last == count - 1;
hitFirst = first == 0;
if (hitLast && hitFirst) {
break;
}
if (hitFirst || next && !hitLast) {
last++;
seedGroupPosition = last;
next = false;
} else if (hitLast || !next && !hitFirst) {
first--;
seedGroupPosition = first;
next = true;
}
}
return AdapterView.INVALID_POSITION;
}
Aggregations