Search in sources :

Example 1 with ListDividerShape

use of net.osmand.plus.views.controls.ListDividerShape in project Osmand by osmandapp.

the class WaypointDialogHelper method getCustomDividers.

private List<Drawable> getCustomDividers(Context ctx, List<Object> points, boolean nightMode) {
    int color = ContextCompat.getColor(ctx, nightMode ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light);
    Shape fullDividerShape = new ListDividerShape(color, 0);
    Shape halfDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(ctx, 56f));
    Shape headerDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(ctx, 16f));
    final ShapeDrawable fullDivider = new ShapeDrawable(fullDividerShape);
    final ShapeDrawable halfDivider = new ShapeDrawable(halfDividerShape);
    final ShapeDrawable headerDivider = new ShapeDrawable(headerDividerShape);
    int divHeight = AndroidUtils.dpToPx(ctx, 1f);
    fullDivider.setIntrinsicHeight(divHeight);
    halfDivider.setIntrinsicHeight(divHeight);
    headerDivider.setIntrinsicHeight(divHeight);
    List<Drawable> res = new ArrayList<>();
    for (int i = 0; i < points.size(); i++) {
        Object obj = points.get(i);
        Object objNext = i + 1 < points.size() ? points.get(i + 1) : null;
        if (objNext == null) {
            break;
        }
        boolean labelView = (obj instanceof Integer);
        boolean bottomDividerViewNext = (objNext instanceof Boolean) && !((Boolean) objNext);
        boolean locationPoint = (obj instanceof LocationPointWrapper);
        boolean locationPointNext = (objNext instanceof LocationPointWrapper);
        Drawable d = null;
        if (locationPointNext) {
            d = locationPoint ? halfDivider : fullDivider;
        } else if (objNext instanceof RadiusItem && labelView) {
            d = headerDivider;
        } else if (locationPoint && !bottomDividerViewNext) {
            d = fullDivider;
        }
        res.add(d);
    }
    return res;
}
Also used : ListDividerShape(net.osmand.plus.views.controls.ListDividerShape) Shape(android.graphics.drawable.shapes.Shape) Drawable(android.graphics.drawable.Drawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) ArrayList(java.util.ArrayList) LocationPointWrapper(net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper) ListDividerShape(net.osmand.plus.views.controls.ListDividerShape) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LocationPoint(net.osmand.data.LocationPoint) SuppressLint(android.annotation.SuppressLint) FavouritePoint(net.osmand.data.FavouritePoint) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Drawable (android.graphics.drawable.Drawable)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1 Shape (android.graphics.drawable.shapes.Shape)1 ArrayList (java.util.ArrayList)1 FavouritePoint (net.osmand.data.FavouritePoint)1 LocationPoint (net.osmand.data.LocationPoint)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 LocationPointWrapper (net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper)1 ListDividerShape (net.osmand.plus.views.controls.ListDividerShape)1