Search in sources :

Example 1 with DensityUtil

use of com.scwang.smartrefresh.layout.util.DensityUtil in project SmartRefreshLayout by scwang90.

the class StoreHouseHeader method initWithPointList.

public StoreHouseHeader initWithPointList(List<float[]> pointList) {
    float drawWidth = 0;
    float drawHeight = 0;
    boolean shouldLayout = mItemList.size() > 0;
    mItemList.clear();
    DensityUtil density = new DensityUtil();
    for (int i = 0; i < pointList.size(); i++) {
        float[] line = pointList.get(i);
        PointF startPoint = new PointF(density.dip2px(line[0]) * mScale, density.dip2px(line[1]) * mScale);
        PointF endPoint = new PointF(density.dip2px(line[2]) * mScale, density.dip2px(line[3]) * mScale);
        drawWidth = Math.max(drawWidth, startPoint.x);
        drawWidth = Math.max(drawWidth, endPoint.x);
        drawHeight = Math.max(drawHeight, startPoint.y);
        drawHeight = Math.max(drawHeight, endPoint.y);
        StoreHouseBarItem item = new StoreHouseBarItem(i, startPoint, endPoint, mTextColor, mLineWidth);
        item.resetPosition(mHorizontalRandomness);
        mItemList.add(item);
    }
    mDrawZoneWidth = (int) Math.ceil(drawWidth);
    mDrawZoneHeight = (int) Math.ceil(drawHeight);
    if (shouldLayout) {
        final View thisView = this;
        thisView.requestLayout();
    }
    return this;
}
Also used : DensityUtil(com.scwang.smartrefresh.layout.util.DensityUtil) StoreHouseBarItem(com.scwang.smartrefresh.header.storehouse.StoreHouseBarItem) PointF(android.graphics.PointF) View(android.view.View)

Aggregations

PointF (android.graphics.PointF)1 View (android.view.View)1 StoreHouseBarItem (com.scwang.smartrefresh.header.storehouse.StoreHouseBarItem)1 DensityUtil (com.scwang.smartrefresh.layout.util.DensityUtil)1