From b88bed8e013b3a954cc8299354e56425d9113f0a Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Mon, 11 Sep 2017 00:44:49 +0300 Subject: [PATCH] Improve create headers algorithm --- .../adapters/MapMarkersHistoryAdapter.java | 57 +++++++------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java index 4eb319e47b..0ec789cef0 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java @@ -57,45 +57,28 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter= 2 && currentDay - markerDay <= 8 && previousHeader != LAST_SEVEN_DAYS_HEADER) { + items.add(LAST_SEVEN_DAYS_HEADER); + previousHeader = LAST_SEVEN_DAYS_HEADER; + } else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousHeader != markerMonth) { + items.add(markerMonth); + previousHeader = markerMonth; + monthsDisplayed += 1; + } else if (currentMonth - markerMonth >= 4 && previousHeader != THIS_YEAR_HEADER) { + items.add(THIS_YEAR_HEADER); + previousHeader = THIS_YEAR_HEADER; } - } else { - if (previousHeader != markerYear) { - items.add(markerYear); - previousHeader = markerYear; - } - items.add(marker); + } else if (previousHeader != markerYear) { + items.add(markerYear); + previousHeader = markerYear; } + items.add(marker); } }