Add sort for history
This commit is contained in:
parent
23749c1088
commit
3a6d81bd52
7 changed files with 292 additions and 44 deletions
38
OsmAnd/res/layout/map_marker_item_date.xml
Normal file
38
OsmAnd/res/layout/map_marker_item_date.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:descendantFocusability="blocksDescendants">
|
||||||
|
|
||||||
|
<include layout="@layout/list_item_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="?attr/bg_color">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/date_title"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
tools:text="Today"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/date_options_button"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:background="@null"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
tools:src="@drawable/ic_overflow_menu_white"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -102,7 +102,6 @@
|
||||||
android:id="@+id/map_marker_options_button"
|
android:id="@+id/map_marker_options_button"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:background="@drawable/marker_circle_background_light_with_inset"
|
android:background="@drawable/marker_circle_background_light_with_inset"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
tools:src="@drawable/ic_action_marker_passed"/>
|
tools:src="@drawable/ic_action_marker_passed"/>
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="today">Today</string>
|
||||||
|
<string name="yesterday">Yesterday</string>
|
||||||
|
<string name="last_seven_days">Last 7 days</string>
|
||||||
|
<string name="this_year">This year</string>
|
||||||
<string name="widget">Widget</string>
|
<string name="widget">Widget</string>
|
||||||
<string name="top_bar">Top bar</string>
|
<string name="top_bar">Top bar</string>
|
||||||
<string name="move_all_to_history">Move all to history</string>
|
<string name="move_all_to_history">Move all to history</string>
|
||||||
|
|
|
@ -10,6 +10,8 @@ import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MapMarkersHelper {
|
public class MapMarkersHelper {
|
||||||
|
@ -172,14 +174,50 @@ public class MapMarkersHelper {
|
||||||
private void loadMarkers() {
|
private void loadMarkers() {
|
||||||
mapMarkers.clear();
|
mapMarkers.clear();
|
||||||
mapMarkersHistory.clear();
|
mapMarkersHistory.clear();
|
||||||
mapMarkers.addAll(markersDbHelper.getActiveMarkers());
|
|
||||||
mapMarkersHistory.addAll(markersDbHelper.getMarkersHistory());
|
List<MapMarker> activeMarkers = markersDbHelper.getActiveMarkers();
|
||||||
|
sortActiveMarkers(activeMarkers);
|
||||||
|
mapMarkers.addAll(activeMarkers);
|
||||||
|
|
||||||
|
List<MapMarker> markersHistory = markersDbHelper.getMarkersHistory();
|
||||||
|
sortHistoryMarkers(markersHistory);
|
||||||
|
mapMarkersHistory.addAll(markersHistory);
|
||||||
|
|
||||||
if (!ctx.isApplicationInitializing()) {
|
if (!ctx.isApplicationInitializing()) {
|
||||||
lookupAddressAll();
|
lookupAddressAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sortActiveMarkers(List<MapMarker> markers) {
|
||||||
|
Collections.sort(markers, new Comparator<MapMarker>() {
|
||||||
|
@Override
|
||||||
|
public int compare(MapMarker mapMarker1, MapMarker mapMarker2) {
|
||||||
|
if (mapMarker1.creationDate > mapMarker2.creationDate) {
|
||||||
|
return -1;
|
||||||
|
} else if (mapMarker1.creationDate == mapMarker2.creationDate) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortHistoryMarkers(List<MapMarker> markers) {
|
||||||
|
Collections.sort(markers, new Comparator<MapMarker>() {
|
||||||
|
@Override
|
||||||
|
public int compare(MapMarker mapMarker1, MapMarker mapMarker2) {
|
||||||
|
if (mapMarker1.visitedDate > mapMarker2.visitedDate) {
|
||||||
|
return -1;
|
||||||
|
} else if (mapMarker1.visitedDate == mapMarker2.visitedDate) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void lookupAddress(final MapMarker mapMarker) {
|
private void lookupAddress(final MapMarker mapMarker) {
|
||||||
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
|
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
|
||||||
cancelPointAddressRequests(mapMarker.point);
|
cancelPointAddressRequests(mapMarker.point);
|
||||||
|
|
|
@ -11,17 +11,28 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
|
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
|
||||||
|
|
||||||
public class MapMarkersHistoryFragment extends Fragment {
|
public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHelper.MapMarkerChangedListener {
|
||||||
|
|
||||||
MapMarkersHistoryAdapter adapter;
|
MapMarkersHistoryAdapter adapter;
|
||||||
|
OsmandApplication app;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
app = getMyApplication();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
app = getMyApplication();
|
||||||
|
|
||||||
final RecyclerView recyclerView = new RecyclerView(getContext());
|
final RecyclerView recyclerView = new RecyclerView(getContext());
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
|
@ -31,22 +42,48 @@ public class MapMarkersHistoryFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view) {
|
public void onItemClick(View view) {
|
||||||
int pos = recyclerView.indexOfChild(view);
|
int pos = recyclerView.indexOfChild(view);
|
||||||
MapMarker marker = adapter.getItem(pos);
|
Object item = adapter.getItem(pos);
|
||||||
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
if (item instanceof MapMarker) {
|
||||||
15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(mapActivity).getName()),
|
MapMarker marker = (MapMarker) item;
|
||||||
false, null);
|
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
||||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(mapActivity).getName()),
|
||||||
((DialogFragment) getParentFragment()).dismiss();
|
false, null);
|
||||||
|
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||||
|
((DialogFragment) getParentFragment()).dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
app.getMapMarkersHelper().addListener(this);
|
||||||
|
|
||||||
return recyclerView;
|
return recyclerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
app.getMapMarkersHelper().removeListener(this);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
void updateAdapter() {
|
void updateAdapter() {
|
||||||
|
adapter.createHeaders();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication)getActivity().getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMapMarkerChanged(MapMarker mapMarker) {
|
||||||
|
updateAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMapMarkersChanged() {
|
||||||
|
updateAdapter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package net.osmand.plus.mapmarkers.adapters;
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
public class MapMarkerDateViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final TextView date;
|
||||||
|
final ImageButton optionsBtn;
|
||||||
|
|
||||||
|
public MapMarkerDateViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
date = itemView.findViewById(R.id.date_title);
|
||||||
|
optionsBtn = itemView.findViewById(R.id.date_options_button);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,17 +10,87 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
import java.text.DateFormatSymbols;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
|
private static final int DATE_TYPE = 1;
|
||||||
|
private static final int MARKER_TYPE = 2;
|
||||||
|
|
||||||
|
private static final int TODAY_HEADER = 56;
|
||||||
|
private static final int YESTERDAY_HEADER = 57;
|
||||||
|
private static final int LAST_SEVEN_DAYS_HEADER = 58;
|
||||||
|
private static final int THIS_YEAR_HEADER = 59;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private List<MapMarker> markers;
|
private List<Object> items = new ArrayList<>();
|
||||||
private MapMarkersHistoryAdapterListener listener;
|
private MapMarkersHistoryAdapterListener listener;
|
||||||
|
|
||||||
public MapMarkersHistoryAdapter(OsmandApplication app) {
|
public MapMarkersHistoryAdapter(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
markers = app.getMapMarkersHelper().getMapMarkersHistory();
|
createHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createHeaders() {
|
||||||
|
items.clear();
|
||||||
|
|
||||||
|
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersHistory();
|
||||||
|
|
||||||
|
int previousHeader = -1;
|
||||||
|
int monthsDisplayed = 0;
|
||||||
|
|
||||||
|
Calendar currentDateCalendar = Calendar.getInstance();
|
||||||
|
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
|
||||||
|
int currentYear = currentDateCalendar.get(Calendar.YEAR);
|
||||||
|
Calendar markerCalendar = Calendar.getInstance();
|
||||||
|
for (int i = 0; i < markersHistory.size(); i++) {
|
||||||
|
MapMarker marker = markersHistory.get(i);
|
||||||
|
markerCalendar.setTimeInMillis(marker.visitedDate);
|
||||||
|
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
|
||||||
|
int markerMonth = markerCalendar.get(Calendar.MONTH);
|
||||||
|
int markerYear = markerCalendar.get(Calendar.YEAR);
|
||||||
|
if (markerYear == currentYear) {
|
||||||
|
if (markerDay == currentDay) {
|
||||||
|
if (previousHeader != TODAY_HEADER) {
|
||||||
|
items.add(TODAY_HEADER);
|
||||||
|
previousHeader = TODAY_HEADER;
|
||||||
|
}
|
||||||
|
items.add(marker);
|
||||||
|
} else if (markerDay == currentDay - 1) {
|
||||||
|
if (previousHeader != YESTERDAY_HEADER) {
|
||||||
|
items.add(YESTERDAY_HEADER);
|
||||||
|
previousHeader = YESTERDAY_HEADER;
|
||||||
|
}
|
||||||
|
items.add(marker);
|
||||||
|
} else if (currentDay - 7 >= markerDay && markerYear != 1970) {
|
||||||
|
if (previousHeader != LAST_SEVEN_DAYS_HEADER) {
|
||||||
|
items.add(LAST_SEVEN_DAYS_HEADER);
|
||||||
|
previousHeader = LAST_SEVEN_DAYS_HEADER;
|
||||||
|
}
|
||||||
|
items.add(marker);
|
||||||
|
} else {
|
||||||
|
if (previousHeader != markerMonth && monthsDisplayed < 3) {
|
||||||
|
items.add(markerMonth);
|
||||||
|
previousHeader = markerMonth;
|
||||||
|
monthsDisplayed += 1;
|
||||||
|
} else if (previousHeader != markerMonth && previousHeader != THIS_YEAR_HEADER) {
|
||||||
|
items.add(THIS_YEAR_HEADER);
|
||||||
|
previousHeader = THIS_YEAR_HEADER;
|
||||||
|
}
|
||||||
|
items.add(marker);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (previousHeader != markerYear) {
|
||||||
|
items.add(markerYear);
|
||||||
|
previousHeader = markerYear;
|
||||||
|
}
|
||||||
|
items.add(marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdapterListener(MapMarkersHistoryAdapterListener listener) {
|
public void setAdapterListener(MapMarkersHistoryAdapterListener listener) {
|
||||||
|
@ -28,53 +98,95 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
if (viewType == MARKER_TYPE) {
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||||
@Override
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View view) {
|
@Override
|
||||||
listener.onItemClick(view);
|
public void onClick(View view) {
|
||||||
}
|
listener.onItemClick(view);
|
||||||
});
|
}
|
||||||
return new MapMarkerItemViewHolder(view);
|
});
|
||||||
|
return new MapMarkerItemViewHolder(view);
|
||||||
|
} else if (viewType == DATE_TYPE) {
|
||||||
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_date, viewGroup, false);
|
||||||
|
return new MapMarkerDateViewHolder(view);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unsupported view type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) {
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||||
IconsCache iconsCache = app.getIconsCache();
|
IconsCache iconsCache = app.getIconsCache();
|
||||||
MapMarker marker = markers.get(pos);
|
if (holder instanceof MapMarkerItemViewHolder) {
|
||||||
|
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
|
||||||
|
final MapMarker marker = (MapMarker) getItem(position);
|
||||||
|
itemViewHolder.iconReorder.setVisibility(View.GONE);
|
||||||
|
|
||||||
holder.iconReorder.setVisibility(View.GONE);
|
int color = MapMarker.getColorId(marker.colorIndex);
|
||||||
|
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||||
|
|
||||||
int color = MapMarker.getColorId(marker.colorIndex);
|
itemViewHolder.title.setText(marker.getName(app));
|
||||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
|
||||||
|
|
||||||
holder.title.setText(marker.getName(app));
|
itemViewHolder.description.setText(marker.visitedDate + "");
|
||||||
|
|
||||||
holder.description.setText(marker.visitedDate + "");
|
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_history));
|
||||||
|
itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_history));
|
@Override
|
||||||
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View view) {
|
||||||
@Override
|
int position = itemViewHolder.getAdapterPosition();
|
||||||
public void onClick(View view) {
|
if (position < 0) {
|
||||||
int position = holder.getAdapterPosition();
|
return;
|
||||||
if (position < 0) {
|
}
|
||||||
return;
|
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
||||||
|
notifyItemRemoved(position);
|
||||||
}
|
}
|
||||||
MapMarker marker = markers.get(position);
|
});
|
||||||
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
} else if (holder instanceof MapMarkerDateViewHolder) {
|
||||||
notifyItemRemoved(position);
|
final MapMarkerDateViewHolder dateViewHolder = (MapMarkerDateViewHolder) holder;
|
||||||
|
final Integer dateHeader = (Integer) getItem(position);
|
||||||
|
String dateString;
|
||||||
|
if (dateHeader == TODAY_HEADER) {
|
||||||
|
dateString = app.getString(R.string.today);
|
||||||
|
} else if (dateHeader == YESTERDAY_HEADER) {
|
||||||
|
dateString = app.getString(R.string.yesterday);
|
||||||
|
} else if (dateHeader == LAST_SEVEN_DAYS_HEADER) {
|
||||||
|
dateString = app.getString(R.string.last_seven_days);
|
||||||
|
} else if (dateHeader == THIS_YEAR_HEADER) {
|
||||||
|
dateString = app.getString(R.string.this_year);
|
||||||
|
} else if (dateHeader % 100 == 0) {
|
||||||
|
dateString = getMonth(dateHeader);
|
||||||
|
} else {
|
||||||
|
dateString = String.valueOf(dateHeader);
|
||||||
}
|
}
|
||||||
});
|
dateViewHolder.date.setText(dateString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
Object item = items.get(position);
|
||||||
|
if (item instanceof MapMarker) {
|
||||||
|
return MARKER_TYPE;
|
||||||
|
} else if (item instanceof Integer) {
|
||||||
|
return DATE_TYPE;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unsupported view type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return markers.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMarker getItem(int position) {
|
public Object getItem(int position) {
|
||||||
return markers.get(position);
|
return items.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMonth(int month) {
|
||||||
|
return new DateFormatSymbols().getMonths()[month-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface MapMarkersHistoryAdapterListener {
|
public interface MapMarkersHistoryAdapterListener {
|
||||||
|
|
Loading…
Reference in a new issue