Search in sources :

Example 6 with Range

use of com.alibaba.android.vlayout.Range in project Tangram-Android by alibaba.

the class GridCard method offsetChildCard.

@Override
public void offsetChildCard(Card anchorCard, int offset) {
    if (anchorCard == null) {
        return;
    }
    ArrayMap<Range<Integer>, Card> newChildren = new ArrayMap<>();
    boolean startOffset = false;
    for (int i = 0, size = mChildren.size(); i < size; i++) {
        Range<Integer> key = mChildren.keyAt(i);
        Card child = mChildren.valueAt(i);
        if (child == anchorCard) {
            Range<Integer> newKey = Range.create(key.getLower().intValue(), key.getUpper().intValue() + offset);
            newChildren.put(newKey, child);
            startOffset = true;
            continue;
        }
        if (startOffset) {
            Range<Integer> newKey = Range.create(key.getLower().intValue() + offset, key.getUpper().intValue() + offset);
            newChildren.put(newKey, child);
        } else {
            newChildren.put(key, child);
        }
    }
    mChildren.clear();
    mChildren.putAll((SimpleArrayMap<? extends Range<Integer>, ? extends Card>) newChildren);
}
Also used : SimpleArrayMap(android.support.v4.util.SimpleArrayMap) ArrayMap(android.support.v4.util.ArrayMap) Range(com.alibaba.android.vlayout.Range) Card(com.tmall.wireless.tangram.dataparser.concrete.Card)

Aggregations

Range (com.alibaba.android.vlayout.Range)6 Card (com.tmall.wireless.tangram.dataparser.concrete.Card)4 CardLoadSupport (com.tmall.wireless.tangram.support.async.CardLoadSupport)3 TargetApi (android.annotation.TargetApi)2 Handler (android.os.Handler)2 NonNull (android.support.annotation.NonNull)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Picasso (com.squareup.picasso.Picasso)2 GroupBasicAdapter (com.tmall.wireless.tangram.core.adapter.GroupBasicAdapter)2 RatioTextView (com.tmall.wireless.tangram.example.data.RatioTextView)2 SimpleImgView (com.tmall.wireless.tangram.example.data.SimpleImgView)2 SingleImageView (com.tmall.wireless.tangram.example.data.SingleImageView)2 TestView (com.tmall.wireless.tangram.example.data.TestView)2 TestViewHolder (com.tmall.wireless.tangram.example.data.TestViewHolder)2 SampleClickSupport (com.tmall.wireless.tangram.example.support.SampleClickSupport)2 AsyncLoader (com.tmall.wireless.tangram.support.async.AsyncLoader)2 AsyncPageLoader (com.tmall.wireless.tangram.support.async.AsyncPageLoader)2