lmw
2023-06-13 4b7d8d9a038f6522df46d0f14fa07eb940a1b34d
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
package com.beloo.widget.chipslayoutmanager.gravity;
 
import android.graphics.Rect;
 
import com.beloo.widget.chipslayoutmanager.layouter.AbstractLayouter;
import com.beloo.widget.chipslayoutmanager.layouter.Item;
 
import java.util.List;
 
class ColumnFillStrategy implements IRowStrategy {
 
    @Override
    public void applyStrategy(AbstractLayouter abstractLayouter, List<Item> row) {
        int difference = GravityUtil.getVerticalDifference(abstractLayouter) / abstractLayouter.getRowSize();
        int offsetDifference = difference;
 
        for (Item item : row) {
            Rect childRect = item.getViewRect();
 
            if (childRect.top == abstractLayouter.getCanvasTopBorder()) {
                //highest view of row
 
                int topDif = childRect.top - abstractLayouter.getCanvasTopBorder();
                //press view to top border
                childRect.top = abstractLayouter.getCanvasTopBorder();
                childRect.bottom -= topDif;
 
                //increase view height from bottom
                childRect.bottom += offsetDifference;
                continue;
            }
 
            childRect.top += offsetDifference;
            offsetDifference += difference;
            childRect.bottom += offsetDifference;
        }
 
    }
}