-
Notifications
You must be signed in to change notification settings - Fork 360
/
LTRRowsCreator.java
51 lines (42 loc) · 2.04 KB
/
LTRRowsCreator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.beloo.widget.chipslayoutmanager.layouter;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import com.beloo.widget.chipslayoutmanager.ChipsLayoutManager;
import com.beloo.widget.chipslayoutmanager.gravity.IGravityModifiersFactory;
import com.beloo.widget.chipslayoutmanager.gravity.IRowStrategy;
import com.beloo.widget.chipslayoutmanager.layouter.breaker.IBreakerFactory;
import com.beloo.widget.chipslayoutmanager.cache.IViewCacheStorage;
import com.beloo.widget.chipslayoutmanager.layouter.criteria.ICriteriaFactory;
import com.beloo.widget.chipslayoutmanager.layouter.placer.IPlacerFactory;
class LTRRowsCreator implements ILayouterCreator {
private RecyclerView.LayoutManager layoutManager;
LTRRowsCreator(RecyclerView.LayoutManager layoutManager) {
this.layoutManager = layoutManager;
}
@Override
public Rect createOffsetRectForBackwardLayouter(Rect anchorRect) {
return new Rect(
0,
anchorRect == null ? layoutManager.getPaddingTop() : anchorRect.top,
//we shouldn't include anchor view here, so anchorLeft is a rightOffset
anchorRect == null ? layoutManager.getPaddingRight() : anchorRect.left,
anchorRect == null ? layoutManager.getPaddingBottom() : anchorRect.bottom);
}
@Override
public Rect createOffsetRectForForwardLayouter(Rect anchorRect) {
return new Rect(
//we should include anchor view here, so anchorLeft is a leftOffset
anchorRect == null ? layoutManager.getPaddingLeft() : anchorRect.left,
anchorRect == null ? layoutManager.getPaddingTop() : anchorRect.top,
0,
anchorRect == null ? layoutManager.getPaddingBottom() : anchorRect.bottom);
}
@Override
public AbstractLayouter.Builder createBackwardBuilder() {
return LTRUpLayouter.newBuilder();
}
@Override
public AbstractLayouter.Builder createForwardBuilder() {
return LTRDownLayouter.newBuilder();
}
}