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;
}
Aggregations