本文整理汇总了Java中org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata类的典型用法代码示例。如果您正苦于以下问题:Java PositionMetadata类的具体用法?Java PositionMetadata怎么用?Java PositionMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PositionMetadata类属于org.holoeverywhere.widget.ExpandableListConnector包,在下文中一共展示了PositionMetadata类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawDivider
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
@Override
void drawDivider(Canvas canvas, Rect bounds, int childIndex) {
int flatListPosition = childIndex + getFirstVisiblePosition();
if (flatListPosition >= 0) {
final int adjustedPosition =
getFlatPositionForConnector(flatListPosition);
PositionMetadata pos = mConnector.getUnflattenedPos(adjustedPosition);
if (pos.position.type ==
ExpandableListPosition.CHILD || pos.isExpanded() &&
pos.groupMetadata.lastChildFlPos != pos.groupMetadata.flPos) {
Drawable divider = mChildDivider;
divider.setBounds(bounds);
divider.draw(canvas);
pos.recycle();
return;
}
pos.recycle();
}
super.drawDivider(canvas, bounds, flatListPosition);
}
示例2: expandGroup
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
public boolean expandGroup(int groupPos, boolean animate) {
ExpandableListPosition elGroupPos = ExpandableListPosition.obtain(
ExpandableListPosition.GROUP, groupPos, -1, -1);
PositionMetadata pm = mConnector.getFlattenedPos(elGroupPos);
elGroupPos.recycle();
boolean retValue = mConnector.expandGroup(pm);
if (mOnGroupExpandListener != null) {
mOnGroupExpandListener.onGroupExpand(groupPos);
}
// TODO Make it works on Eclair
if (animate && VERSION.SDK_INT >= VERSION_CODES.FROYO) {
final int groupFlatPos = pm.position.flatListPos;
final int shiftedGroupPosition = groupFlatPos + getHeaderViewsCount();
smoothScrollToPosition(shiftedGroupPosition + mAdapter.getChildrenCount(groupPos),
shiftedGroupPosition);
}
pm.recycle();
return retValue;
}
示例3: getIndicator
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
private Drawable getIndicator(PositionMetadata pos) {
Drawable indicator;
if (pos.position.type == ExpandableListPosition.GROUP) {
indicator = mGroupIndicator;
if (indicator != null && indicator.isStateful()) {
boolean isEmpty = pos.groupMetadata == null ||
pos.groupMetadata.lastChildFlPos == pos.groupMetadata.flPos;
final int stateSetIndex =
(pos.isExpanded() ? 1 : 0) | // Expanded?
(isEmpty ? 2 : 0); // Empty?
indicator.setState(GROUP_STATE_SETS[stateSetIndex]);
}
} else {
indicator = mChildIndicator;
if (indicator != null && indicator.isStateful()) {
final int stateSet[] = pos.position.flatListPos == pos.groupMetadata.lastChildFlPos
? CHILD_LAST_STATE_SET
: EMPTY_STATE_SET;
indicator.setState(stateSet);
}
}
return indicator;
}
示例4: setSelectedChild
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
public boolean setSelectedChild(int groupPosition, int childPosition, boolean shouldExpandGroup) {
ExpandableListPosition elChildPos = ExpandableListPosition.obtainChildPosition(
groupPosition, childPosition);
PositionMetadata flatChildPos = mConnector.getFlattenedPos(elChildPos);
if (flatChildPos == null) {
if (!shouldExpandGroup) {
return false;
}
expandGroup(groupPosition);
flatChildPos = mConnector.getFlattenedPos(elChildPos);
if (flatChildPos == null) {
throw new IllegalStateException("Could not find child");
}
}
int absoluteFlatPosition = getAbsoluteFlatPosition(flatChildPos.position.flatListPos);
super.setSelection(absoluteFlatPosition);
elChildPos.recycle();
flatChildPos.recycle();
return true;
}
示例5: createContextMenuInfo
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
@Override
protected ContextMenuInfo createContextMenuInfo(View view, int flatListPosition, long id) {
if (isHeaderOrFooterPosition(flatListPosition)) {
return super.createContextMenuInfo(view, flatListPosition, id);
}
final int adjustedPosition = getFlatPositionForConnector(flatListPosition);
PositionMetadata pm = mConnector.getUnflattenedPos(adjustedPosition);
ExpandableListPosition pos = pm.position;
id = getChildOrGroupId(pos);
long packedPosition = pos.getPackedPosition();
pm.recycle();
return new ExpandableListContextMenuInfo(view, packedPosition, id);
}
示例6: getExpandableListPosition
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
public long getExpandableListPosition(int flatListPosition) {
if (isHeaderOrFooterPosition(flatListPosition)) {
return PACKED_POSITION_VALUE_NULL;
}
final int adjustedPosition = getFlatPositionForConnector(flatListPosition);
PositionMetadata pm = mConnector.getUnflattenedPos(adjustedPosition);
long packedPos = pm.position.getPackedPosition();
pm.recycle();
return packedPos;
}
示例7: getFlatListPosition
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
public int getFlatListPosition(long packedPosition) {
ExpandableListPosition elPackedPos = ExpandableListPosition
.obtainPosition(packedPosition);
PositionMetadata pm = mConnector.getFlattenedPos(elPackedPos);
elPackedPos.recycle();
final int flatListPosition = pm.position.flatListPos;
pm.recycle();
return getAbsoluteFlatPosition(flatListPosition);
}
示例8: setSelectedGroup
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
public void setSelectedGroup(int groupPosition) {
ExpandableListPosition elGroupPos = ExpandableListPosition
.obtainGroupPosition(groupPosition);
PositionMetadata pm = mConnector.getFlattenedPos(elGroupPos);
elGroupPos.recycle();
final int absoluteFlatPosition = getAbsoluteFlatPosition(pm.position.flatListPos);
super.setSelection(absoluteFlatPosition);
pm.recycle();
}
示例9: dispatchDraw
import org.holoeverywhere.widget.ExpandableListConnector.PositionMetadata; //导入依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mChildIndicator == null && mGroupIndicator == null) {
return;
}
int saveCount = 0;
final boolean clipToPadding = mClipToPadding;
if (clipToPadding) {
saveCount = canvas.save();
final int scrollX = getScrollX();
final int scrollY = getScrollY();
canvas.clipRect(scrollX + getPaddingLeft(), scrollY + getPaddingTop(),
scrollX + getRight() - getLeft() - getPaddingRight(),
scrollY + getBottom() - getTop() - getPaddingBottom());
}
final int headerViewsCount = getHeaderViewsCount();
final int lastChildFlPos = getCount() - getFooterViewsCount() - headerViewsCount - 1;
final int myB = getBottom();
PositionMetadata pos;
View item;
Drawable indicator;
int t, b;
int lastItemType = ~(ExpandableListPosition.CHILD | ExpandableListPosition.GROUP);
final Rect indicatorRect = mIndicatorRect;
final int childCount = getChildCount();
for (int i = 0, childFlPos = getFirstVisiblePosition() - headerViewsCount; i < childCount; i++, childFlPos++) {
if (childFlPos < 0) {
continue;
} else if (childFlPos > lastChildFlPos) {
break;
}
item = getChildAt(i);
t = item.getTop();
b = item.getBottom();
if (b < 0 || t > myB) {
continue;
}
pos = mConnector.getUnflattenedPos(childFlPos);
if (pos.position.type != lastItemType) {
if (pos.position.type == ExpandableListPosition.CHILD) {
indicatorRect.left = mChildIndicatorLeft == CHILD_INDICATOR_INHERIT ?
mIndicatorLeft : mChildIndicatorLeft;
indicatorRect.right = mChildIndicatorRight == CHILD_INDICATOR_INHERIT ?
mIndicatorRight : mChildIndicatorRight;
} else {
indicatorRect.left = mIndicatorLeft;
indicatorRect.right = mIndicatorRight;
}
indicatorRect.left += getPaddingLeft();
indicatorRect.right += getPaddingLeft();
lastItemType = pos.position.type;
}
if (indicatorRect.left != indicatorRect.right) {
if (isStackFromBottom()) {
indicatorRect.top = t;
indicatorRect.bottom = b;
} else {
indicatorRect.top = t;
indicatorRect.bottom = b;
}
indicator = getIndicator(pos);
if (indicator != null) {
indicator.setBounds(indicatorRect);
indicator.draw(canvas);
}
}
pos.recycle();
}
if (clipToPadding) {
canvas.restoreToCount(saveCount);
}
}