本文整理汇总了Java中com.alibaba.android.vlayout.Range类的典型用法代码示例。如果您正苦于以下问题:Java Range类的具体用法?Java Range怎么用?Java Range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Range类属于com.alibaba.android.vlayout包,在下文中一共展示了Range类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSiblingStyleByPosition
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
public GridRangeStyle findSiblingStyleByPosition(int position) {
GridRangeStyle rangeStyle = null;
if (mParent != null) {
ArrayMap<Range<Integer>, GridRangeStyle> siblings = mParent.mChildren;
for (int i = 0, size = siblings.size(); i < size; i++) {
Range range = siblings.keyAt(i);
if (range.contains(position)) {
GridRangeStyle childRangeStyle = siblings.valueAt(i);
if (!childRangeStyle.equals(this)) {
rangeStyle = childRangeStyle;
}
break;
}
}
}
return rangeStyle;
}
示例2: setRange
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
/**
* @param start offset relative to its parent
* @param end offset relative to its parent
*/
public void setRange(int start, int end) {
mRange = Range.create(start, end);
if (!mChildren.isEmpty()) {
SimpleArrayMap<Range<Integer>, T> newMap = new SimpleArrayMap<>();
for (int i = 0, size = mChildren.size(); i < size; i++) {
T rangeStyle = mChildren.valueAt(i);
int newStart = rangeStyle.getOriginStartOffset() + start;
int newEnd = rangeStyle.getOriginEndOffset() + start;
Range<Integer> newRange = Range.create(newStart, newEnd);
newMap.put(newRange, rangeStyle);
rangeStyle.setRange(newStart, newEnd);
}
mChildren.clear();
mChildren.putAll(newMap);
}
}
示例3: isRecyclable
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@Override
public boolean isRecyclable(int childPos, int startIndex, int endIndex, LayoutManagerHelper helper, boolean fromStart) {
Range<Integer> range = getRange();
if (range.contains(childPos)) {
if (hasHeader && childPos == getRange().getLower()) {
return true;
}
if (hasFooter && childPos == getRange().getUpper()) {
return true;
}
Range<Integer> childRange = Range.create(range.getLower() + (hasHeader ? 1 : 0),
range.getUpper() - (hasFooter ? 1 : 0));
return Range.create(startIndex, endIndex).contains(childRange);
} else {
Log.w(TAG, "Child item not match");
return true;
}
}
示例4: onBindViewHolder
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@Override
public void onBindViewHolder(BinderViewHolder<BaseCell, ? extends View> holder, int position) {
super.onBindViewHolder(holder, position);
int idx = findCardIdxFor(position);
if (idx >= 0) {
Pair<Range<Integer>, Card> pair = mCards.get(idx);
pair.second.onBindCell(position - pair.first.getLower(), position, mLastBindPosition < 0 || mLastBindPosition < position);
PageDetectorSupport pageDetectorSupport = pair.second.serviceManager
.getService(PageDetectorSupport.class);
if (pageDetectorSupport != null) {
pageDetectorSupport.onBindItem(position, mLastBindPosition < 0 || mLastBindPosition < position, getItemByPosition(position));
}
}
mLastBindPosition = position;
}
示例5: transformCards
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@NonNull
@Override
protected List<LayoutHelper> transformCards(@Nullable List<Card> cards, @NonNull List<BaseCell> data, @NonNull List<Pair<Range<Integer>, Card>> rangeCards) {
if (cards == null) {
return super.transformCards(cards, data, rangeCards);
}
/* record card id, used in {@link #getItems} to clean "forLabel" cards */
for (Card card : cards) {
if (!TextUtils.isEmpty(card.id)) {
mIdCardCache.put(card.id, card);
}
}
List<LayoutHelper> layoutHelpers = super.transformCards(cards, data, rangeCards);
// clean cache after used
mIdCardCache.clear();
return layoutHelpers;
}
示例6: removeComponent
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
/**
* remove a component
*
* @param position the position to be removes
*/
@Override
public void removeComponent(int position) {
if (mData != null) {
if (position >= 0 && position <= mData.size() - 1) {
BaseCell cell = mData.remove(position);
boolean changed = cell != null;
int idx = findCardIdxFor(position);
if (idx >= 0) {
Pair<Range<Integer>, Card> pair = mCards.get(idx);
pair.second.removeCellSilently(cell);
}
if (changed) {
notifyItemRemoved(position);
int last = mLayoutManager.findLastVisibleItemPosition();
notifyItemRangeChanged(position, last - position);
}
}
}
}
示例7: findCardIdxFor
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
/**
*
* @param position cell's adapter position
* @return the card index of given cell's position
*/
public int findCardIdxFor(int position) {
int low = 0, mid = mCards.size(), high = mid - 1;
while (low <= high) {
mid = (low + high) >>> 1;
Pair<Range<Integer>, L> pair = mCards.get(mid);
if (pair == null) return -1;
if (pair.first.getLower() <= position && pair.first.getUpper() > position) {
return mid;
} else if (pair.first.getUpper() <= position) {
low = mid + 1;
} else {
high = mid - 1;
}
}
return -1;
}
示例8: findRangeStyleByPosition
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
public GridRangeStyle findRangeStyleByPosition(int position) {
GridRangeStyle rangeStyle = this;
for (int i = 0, size = mChildren.size(); i < size; i++) {
Range range = mChildren.keyAt(i);
if (range.contains(position)) {
rangeStyle = mChildren.valueAt(i);
break;
}
}
return rangeStyle;
}
示例9: isRecyclable
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@Override
public boolean isRecyclable(int childPos, int startIndex, int endIndex, LayoutManagerHelper helper, boolean fromStart) {
Range<Integer> range = getRange();
if (range.contains(childPos)) {
return Range.create(startIndex, endIndex).contains(range);
} else {
Log.w(TAG, "Child item not match");
return true;
}
}
示例10: findRangeStyle
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
private GridRangeStyle findRangeStyle(GridRangeStyle rangeStyle, int position){
for (int i = 0, size = rangeStyle.mChildren.size(); i < size; i++) {
GridRangeStyle childRangeStyle = rangeStyle.mChildren.valueAt(i);
Range range = rangeStyle.mChildren.keyAt(i);
if (!childRangeStyle.isChildrenEmpty()){
return findRangeStyle(childRangeStyle, position);
} else if (range.contains(position)) {
return rangeStyle.mChildren.valueAt(i);
}
}
return rangeStyle;
}
示例11: addChildCard
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@Override
public void addChildCard(Card card) {
if (card == null) {
return;
}
List<BaseCell> subCells = card.getCells();
if (subCells != null && !subCells.isEmpty()) {
addCells(card.getCells());
int startOffset = mCells.indexOf(subCells.get(0));
int endOffset = mCells.indexOf(subCells.get(subCells.size() - 1));
Range range = Range.create(startOffset, endOffset);
mChildren.put(range, card);
}
}
示例12: getCardRange
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
@Override
public Range<Integer> getCardRange(String id) {
if (TextUtils.isEmpty(id)) {
return Range.create(0, 0);
}
List<Card> cards = getGroups();
for (int i = 0, size = cards.size(); i < size; i++) {
Card c = cards.get(i);
if (id.equals(c.id)) {
return getCardRange(c);
}
}
return Range.create(0, 0);
}
示例13: getCardRange
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
/**
* @param index card index
* @return card range at given index
*/
public Pair<Range<Integer>, L> getCardRange(int index) {
if (index >= 0 && index <= mCards.size() - 1) {
return mCards.get(index);
} else {
return null;
}
}
示例14: getGroups
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
/**
* @return total card list
*/
public List<L> getGroups() {
List<L> cards = new ArrayList<>(mCards.size());
for (int i = 0, size = mCards.size(); i < size; i++) {
Pair<Range<Integer>, L> pair = mCards.get(i);
cards.add(pair.second);
}
return cards;
}
示例15: getRange
import com.alibaba.android.vlayout.Range; //导入依赖的package包/类
public Range<Integer> getRange() {
return mRange;
}