Merge remote-tracking branch 'origin/sasha_pasha_branch' into sasha_pasha_branch
This commit is contained in:
commit
cb42be9d38
7 changed files with 386 additions and 30 deletions
|
@ -27,9 +27,11 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
|
||||
|
||||
|
@ -264,6 +266,55 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public List<MapMarker> getMarkersSortedByGroup() {
|
||||
Map<String, MapMarkerGroup> groupsMap = new LinkedHashMap<>();
|
||||
List<MapMarker> noGroup = new ArrayList<>();
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
String groupName = marker.groupName;
|
||||
if (groupName == null) {
|
||||
noGroup.add(marker);
|
||||
} else {
|
||||
MapMarkerGroup group = groupsMap.get(groupName);
|
||||
if (group == null) {
|
||||
group = new MapMarkerGroup(groupName, marker.creationDate);
|
||||
groupsMap.put(groupName, group);
|
||||
} else {
|
||||
long markerCreationDate = marker.creationDate;
|
||||
if (markerCreationDate < group.getCreationDate()) {
|
||||
group.setCreationDate(markerCreationDate);
|
||||
}
|
||||
}
|
||||
group.getMapMarkers().add(marker);
|
||||
}
|
||||
}
|
||||
List<MapMarkerGroup> groups = new ArrayList<>(groupsMap.values());
|
||||
sortGroups(groups);
|
||||
|
||||
List<MapMarker> markers = new ArrayList<>();
|
||||
markers.addAll(noGroup);
|
||||
for (MapMarkerGroup group : groups) {
|
||||
markers.addAll(group.getMapMarkers());
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
private void sortGroups(List<MapMarkerGroup> groups) {
|
||||
Collections.sort(groups, new Comparator<MapMarkerGroup>() {
|
||||
@Override
|
||||
public int compare(MapMarkerGroup group1, MapMarkerGroup group2) {
|
||||
long t1 = group1.creationDate;
|
||||
long t2 = group2.creationDate;
|
||||
if (t1 > t2) {
|
||||
return -1;
|
||||
} else if (t1 == t2) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sortHistoryMarkers() {
|
||||
sortMarkers(true, null);
|
||||
}
|
||||
|
@ -791,4 +842,39 @@ public class MapMarkersHelper {
|
|||
}
|
||||
GPXUtilities.writeGpxFile(fout, file, ctx);
|
||||
}
|
||||
|
||||
public static class MapMarkerGroup {
|
||||
private String name;
|
||||
private List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
private long creationDate;
|
||||
|
||||
public MapMarkerGroup(String name, long creationDate) {
|
||||
this.name = name;
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MapMarker> getMapMarkers() {
|
||||
return mapMarkers;
|
||||
}
|
||||
|
||||
public void setMapMarkers(List<MapMarker> mapMarkers) {
|
||||
this.mapMarkers = mapMarkers;
|
||||
}
|
||||
|
||||
public long getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public void setCreationDate(long creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,25 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
public class MapMarkersGroupsFragment extends Fragment {
|
||||
public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||
|
||||
public static final String TAG = "MapMarkersGroupsFragment";
|
||||
|
||||
private MapMarkersGroupsAdapter adapter;
|
||||
private Float heading;
|
||||
private Location location;
|
||||
private boolean locationUpdateStarted;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
@ -26,6 +37,7 @@ public class MapMarkersGroupsFragment extends Fragment {
|
|||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
|
||||
adapter = new MapMarkersGroupsAdapter(mapActivity);
|
||||
recyclerView.setAdapter(adapter);
|
||||
return recyclerView;
|
||||
}
|
||||
|
||||
|
@ -34,4 +46,91 @@ public class MapMarkersGroupsFragment extends Fragment {
|
|||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
|
||||
startLocationUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
stopLocationUpdate();
|
||||
}
|
||||
|
||||
void startLocationUpdate() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && !locationUpdateStarted) {
|
||||
locationUpdateStarted = true;
|
||||
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||
app.getLocationProvider().addCompassListener(this);
|
||||
app.getLocationProvider().addLocationListener(this);
|
||||
updateLocationUi();
|
||||
}
|
||||
}
|
||||
|
||||
void stopLocationUpdate() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && locationUpdateStarted) {
|
||||
locationUpdateStarted = false;
|
||||
app.getLocationProvider().removeLocationListener(this);
|
||||
app.getLocationProvider().removeCompassListener(this);
|
||||
app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
boolean newLocation = this.location == null && location != null;
|
||||
boolean locationChanged = this.location != null && location != null
|
||||
&& this.location.getLatitude() != location.getLatitude()
|
||||
&& this.location.getLongitude() != location.getLongitude();
|
||||
if (newLocation || locationChanged) {
|
||||
this.location = location;
|
||||
updateLocationUi();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCompassValue(float value) {
|
||||
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction)
|
||||
// on non-compass devices
|
||||
float lastHeading = heading != null ? heading : 99;
|
||||
heading = value;
|
||||
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
||||
updateLocationUi();
|
||||
} else {
|
||||
heading = lastHeading;
|
||||
}
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
if (getActivity() != null) {
|
||||
return ((MapActivity) getActivity()).getMyApplication();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateLocationUi() {
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
if (mapActivity != null && adapter != null) {
|
||||
mapActivity.getMyApplication().runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (location == null) {
|
||||
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
}
|
||||
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
|
||||
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
|
||||
|
||||
adapter.setUseCenter(useCenter);
|
||||
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
|
||||
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkerDateViewHolder;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkerHeaderViewHolder;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
|
|||
|
||||
@Override
|
||||
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof MapMarkerDateViewHolder) {
|
||||
if (viewHolder instanceof MapMarkerHeaderViewHolder) {
|
||||
return 0;
|
||||
}
|
||||
return super.getSwipeDirs(recyclerView, viewHolder);
|
||||
|
|
|
@ -7,12 +7,12 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class MapMarkerDateViewHolder extends RecyclerView.ViewHolder {
|
||||
public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView date;
|
||||
final ImageButton optionsBtn;
|
||||
|
||||
public MapMarkerDateViewHolder(View itemView) {
|
||||
public MapMarkerHeaderViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
date = itemView.findViewById(R.id.date_title);
|
||||
optionsBtn = itemView.findViewById(R.id.date_options_button);
|
|
@ -5,47 +5,218 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||
public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private List<MapMarkersHelper.MapMarker> markers;
|
||||
private static final int HEADER_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 List<Object> items = new ArrayList<>();
|
||||
private boolean night;
|
||||
private int screenOrientation;
|
||||
private LatLon location;
|
||||
private Float heading;
|
||||
private boolean useCenter;
|
||||
|
||||
public MapMarkersGroupsAdapter(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
|
||||
this.app = mapActivity.getMyApplication();
|
||||
night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
createDisplayGroups();
|
||||
}
|
||||
|
||||
public void createDisplayGroups() {
|
||||
items.clear();
|
||||
|
||||
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMarkersSortedByGroup();
|
||||
|
||||
int previousDateHeader = -1;
|
||||
String previousNameHeader = "";
|
||||
int monthsDisplayed = 0;
|
||||
|
||||
Calendar currentDateCalendar = Calendar.getInstance();
|
||||
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
|
||||
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int currentMonth = currentDateCalendar.get(Calendar.MONTH);
|
||||
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.creationDate);
|
||||
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int markerMonth = markerCalendar.get(Calendar.MONTH);
|
||||
int markerYear = markerCalendar.get(Calendar.YEAR);
|
||||
String markerGroupName = marker.groupName;
|
||||
if (markerGroupName != null && markerGroupName.equals("")) {
|
||||
markerGroupName = app.getString(R.string.shared_string_favorites);
|
||||
}
|
||||
if (markerGroupName == null && markerYear == currentYear) {
|
||||
if (markerDay == currentDay && previousDateHeader != TODAY_HEADER) {
|
||||
items.add(TODAY_HEADER);
|
||||
previousDateHeader = TODAY_HEADER;
|
||||
} else if (markerDay == currentDay - 1 && previousDateHeader != YESTERDAY_HEADER) {
|
||||
items.add(YESTERDAY_HEADER);
|
||||
previousDateHeader = YESTERDAY_HEADER;
|
||||
} else if (currentDay - markerDay >= 2 && currentDay - markerDay <= 8 && previousDateHeader != LAST_SEVEN_DAYS_HEADER) {
|
||||
items.add(LAST_SEVEN_DAYS_HEADER);
|
||||
previousDateHeader = LAST_SEVEN_DAYS_HEADER;
|
||||
} else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousDateHeader != markerMonth) {
|
||||
items.add(markerMonth);
|
||||
previousDateHeader = markerMonth;
|
||||
monthsDisplayed += 1;
|
||||
} else if (currentMonth - markerMonth >= 4 && previousDateHeader != THIS_YEAR_HEADER) {
|
||||
items.add(THIS_YEAR_HEADER);
|
||||
previousDateHeader = THIS_YEAR_HEADER;
|
||||
}
|
||||
} else if (markerGroupName == null && previousDateHeader != markerYear) {
|
||||
items.add(markerYear);
|
||||
previousDateHeader = markerYear;
|
||||
} else if (markerGroupName != null && !previousNameHeader.equals(markerGroupName)) {
|
||||
items.add(markerGroupName);
|
||||
previousNameHeader = markerGroupName;
|
||||
}
|
||||
items.add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocation(LatLon location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setHeading(Float heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public void setUseCenter(boolean useCenter) {
|
||||
this.useCenter = useCenter;
|
||||
}
|
||||
|
||||
public void setScreenOrientation(int screenOrientation) {
|
||||
this.screenOrientation = screenOrientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||
return new MapMarkerItemViewHolder(view);
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == MARKER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||
return new MapMarkerItemViewHolder(view);
|
||||
} else if (viewType == HEADER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_header, viewGroup, false);
|
||||
return new MapMarkerHeaderViewHolder(view);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MapMarkerItemViewHolder mapMarkerItemViewHolder, int i) {
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
MapMarkersHelper.MapMarker marker = markers.get(i);
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
if (holder instanceof MapMarkerItemViewHolder) {
|
||||
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
|
||||
final MapMarker marker = (MapMarker) getItem(position);
|
||||
itemViewHolder.iconReorder.setVisibility(View.GONE);
|
||||
|
||||
int color = MapMarker.getColorId(marker.colorIndex);
|
||||
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||
|
||||
itemViewHolder.title.setText(marker.getName(app));
|
||||
|
||||
itemViewHolder.description.setText(app.getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.visitedDate))));
|
||||
|
||||
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
|
||||
itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// int position = itemViewHolder.getAdapterPosition();
|
||||
// if (position < 0) {
|
||||
// return;
|
||||
// }
|
||||
// app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
||||
// notifyItemRemoved(position);
|
||||
}
|
||||
});
|
||||
itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.iconDirection.setVisibility(View.GONE);
|
||||
itemViewHolder.leftPointSpace.setVisibility(View.GONE);
|
||||
itemViewHolder.rightPointSpace.setVisibility(View.GONE);
|
||||
if (position == getItemCount() - 1) {
|
||||
itemViewHolder.bottomShadow.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.divider.setVisibility(View.GONE);
|
||||
} else {
|
||||
itemViewHolder.bottomShadow.setVisibility(View.GONE);
|
||||
itemViewHolder.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (holder instanceof MapMarkerHeaderViewHolder) {
|
||||
final MapMarkerHeaderViewHolder dateViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final Object header = getItem(position);
|
||||
String headerString;
|
||||
if (header instanceof Integer) {
|
||||
Integer dateHeader = (Integer) header;
|
||||
if (dateHeader == TODAY_HEADER) {
|
||||
headerString = app.getString(R.string.today);
|
||||
} else if (dateHeader == YESTERDAY_HEADER) {
|
||||
headerString = app.getString(R.string.yesterday);
|
||||
} else if (dateHeader == LAST_SEVEN_DAYS_HEADER) {
|
||||
headerString = app.getString(R.string.last_seven_days);
|
||||
} else if (dateHeader == THIS_YEAR_HEADER) {
|
||||
headerString = app.getString(R.string.this_year);
|
||||
} else if (dateHeader / 100 == 0) {
|
||||
headerString = getMonth(dateHeader);
|
||||
} else {
|
||||
headerString = String.valueOf(dateHeader);
|
||||
}
|
||||
} else if (header instanceof String) {
|
||||
headerString = (String) header;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported header");
|
||||
}
|
||||
dateViewHolder.date.setText(headerString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Object item = items.get(position);
|
||||
if (item instanceof MapMarker) {
|
||||
return MARKER_TYPE;
|
||||
} else if (item instanceof String || item instanceof Integer) {
|
||||
return HEADER_TYPE;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return markers.size();
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public MapMarkersHelper.MapMarker getItem(int position) {
|
||||
return markers.get(position);
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
public List<MapMarkersHelper.MapMarker> getItems() {
|
||||
return markers;
|
||||
}
|
||||
private String getMonth(int month) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("LLLL", Locale.getDefault());
|
||||
Date date = new Date();
|
||||
date.setMonth(month);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Locale;
|
|||
|
||||
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private static final int DATE_TYPE = 1;
|
||||
private static final int HEADER_TYPE = 1;
|
||||
private static final int MARKER_TYPE = 2;
|
||||
|
||||
private static final int TODAY_HEADER = 56;
|
||||
|
@ -97,9 +97,9 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
}
|
||||
});
|
||||
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 if (viewType == HEADER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_header, viewGroup, false);
|
||||
return new MapMarkerHeaderViewHolder(view);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
itemViewHolder.bottomShadow.setVisibility(View.GONE);
|
||||
itemViewHolder.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (holder instanceof MapMarkerDateViewHolder) {
|
||||
final MapMarkerDateViewHolder dateViewHolder = (MapMarkerDateViewHolder) holder;
|
||||
} else if (holder instanceof MapMarkerHeaderViewHolder) {
|
||||
final MapMarkerHeaderViewHolder dateViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final Integer dateHeader = (Integer) getItem(position);
|
||||
String dateString;
|
||||
if (dateHeader == TODAY_HEADER) {
|
||||
|
@ -170,7 +170,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
if (item instanceof MapMarker) {
|
||||
return MARKER_TYPE;
|
||||
} else if (item instanceof Integer) {
|
||||
return DATE_TYPE;
|
||||
return HEADER_TYPE;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue