Merge pull request #1087 from Bars107/master

Fixed tracks menu and returned delete for search history.
This commit is contained in:
vshcherb 2015-02-26 19:06:08 +01:00
commit cd757b4cd8
5 changed files with 154 additions and 70 deletions

View file

@ -51,10 +51,18 @@
android:id="@+id/turn_off_all" android:id="@+id/turn_off_all"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="?attr/dashboardGeneralButtonStyle"
android:textColor="@color/color_distance"
android:text="@string/turn_off_all"/> android:text="@string/turn_off_all"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<ListView <ListView
android:id="@+id/gpx_on_map" android:id="@+id/gpx_on_map"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -100,12 +100,7 @@
android:src="@drawable/ic_action_gsave_dark"/> android:src="@drawable/ic_action_gsave_dark"/>
<CheckBox <include layout="@layout/check_item_rel" />
android:id="@+id/check"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:focusable="false"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>

View file

@ -13,8 +13,6 @@
<Button <Button
android:id="@+id/clearAll" android:id="@+id/clearAll"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:background="?attr/downloadButtonBackground" android:background="?attr/downloadButtonBackground"
android:textColor="?attr/pstsTextColor" android:textColor="?attr/pstsTextColor"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -67,6 +67,7 @@ import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -82,8 +83,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private List<GpxInfo> selectedItems = new ArrayList<>(); private List<GpxInfo> selectedItems = new ArrayList<>();
private ActionMode actionMode; private ActionMode actionMode;
private LoadGpxTask asyncLoader; private LoadGpxTask asyncLoader;
private GpxIndexesAdapter listAdapter; private GpxIndexesAdapter allGpxAdapter;
private ShowedOnMapAdapter showOnMapAdapter; private ShowedOnMapAdapter showOnMapGpxAdapter;
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US); MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
private LoadLocalIndexDescriptionTask descriptionLoader; private LoadLocalIndexDescriptionTask descriptionLoader;
private ContextMenuAdapter optionsMenuAdapter; private ContextMenuAdapter optionsMenuAdapter;
@ -102,8 +103,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
asyncLoader = new LoadGpxTask(); asyncLoader = new LoadGpxTask();
selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper(); selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper();
savingTrackHelper = ((OsmandApplication) activity.getApplication()).getSavingTrackHelper(); savingTrackHelper = ((OsmandApplication) activity.getApplication()).getSavingTrackHelper();
listAdapter = new GpxIndexesAdapter(getActivity()); allGpxAdapter = new GpxIndexesAdapter(getActivity());
setAdapter(listAdapter); setAdapter(allGpxAdapter);
} }
public List<GpxInfo> getSelectedItems() { public List<GpxInfo> getSelectedItems() {
@ -122,10 +123,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
private void createShowedOnMapsView(View v) { private void createShowedOnMapsView(View v) {
v.findViewById(R.id.on_map_layout).setVisibility(View.GONE); ListView onMap = (ListView) v.findViewById(R.id.gpx_on_map);
ListView onMap = (ListView)v.findViewById(R.id.gpx_on_map); showOnMapGpxAdapter = new ShowedOnMapAdapter(getActivity(), R.layout.dash_gpx_track_item);
showOnMapAdapter = new ShowedOnMapAdapter(getActivity(), R.layout.dash_gpx_track_item); onMap.setAdapter(showOnMapGpxAdapter);
onMap.setAdapter(showOnMapAdapter); v.findViewById(R.id.turn_off_all).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOnMapGpxAdapter.notifyDataSetChanged();
}
});
} }
@Override @Override
@ -136,6 +142,20 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
} }
private void setShowedOnMapVisibility(boolean visibility) {
View v = getView();
if (v == null) {
return;
}
//temporary hiding this view
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
/* if (visibility) {
v.findViewById(R.id.on_map_layout).setVisibility(View.VISIBLE);
} else {
v.findViewById(R.id.on_map_layout).setVisibility(View.GONE);
}*/
}
private void updateCurrentTrack(View v) { private void updateCurrentTrack(View v) {
if (v == null) { if (v == null) {
return; return;
@ -163,7 +183,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (this.adapter != null) { if (this.adapter != null) {
listView.setAdapter(this.adapter); listView.setAdapter(this.adapter);
} }
setHasOptionsMenu(true);
((TextView) v.findViewById(R.id.name)).setText(R.string.currently_recording_track); ((TextView) v.findViewById(R.id.name)).setText(R.string.currently_recording_track);
v.findViewById(R.id.time_icon).setVisibility(View.GONE); v.findViewById(R.id.time_icon).setVisibility(View.GONE);
@ -246,13 +266,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {
listAdapter.getFilter().filter(query); allGpxAdapter.getFilter().filter(query);
return true; return true;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
listAdapter.getFilter().filter(newText); allGpxAdapter.getFilter().filter(newText);
return true; return true;
} }
}); });
@ -383,7 +403,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void openShowOnMapMode() { private void openShowOnMapMode() {
enableSelectionMode(true); enableSelectionMode(true);
selectedItems.clear(); selectedItems.clear();
final Set<GpxInfo> originalSelectedItems = listAdapter.getSelectedGpx(); final Set<GpxInfo> originalSelectedItems = allGpxAdapter.getSelectedGpx();
selectedItems.addAll(originalSelectedItems); selectedItems.addAll(originalSelectedItems);
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
@ -424,11 +444,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
enableSelectionMode(false); enableSelectionMode(false);
getView().findViewById(R.id.memory_size).setVisibility(View.GONE); getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
runSelection(false); runSelection(false);
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
}); });
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
@ -440,7 +460,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
value = value.substring(0, value.length() - 3); value = value.substring(0, value.length() - 3);
} }
final String actionButton = value; final String actionButton = value;
if (listAdapter.getGroupCount() == 0) { if (allGpxAdapter.getGroupCount() == 0) {
AccessibleToast.makeText(getActivity(), app.getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show(); AccessibleToast.makeText(getActivity(), app.getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
return; return;
} }
@ -485,7 +505,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void onDestroyActionMode(ActionMode mode) { public void onDestroyActionMode(ActionMode mode) {
enableSelectionMode(false); enableSelectionMode(false);
getView().findViewById(R.id.memory_size).setVisibility(View.GONE); getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
}); });
@ -494,7 +514,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
((TextView) getView().findViewById(R.id.memory_size)).setText(R.string.local_index_upload_gpx_description); ((TextView) getView().findViewById(R.id.memory_size)).setText(R.string.local_index_upload_gpx_description);
((TextView) getView().findViewById(R.id.memory_size)).setVisibility(View.VISIBLE); ((TextView) getView().findViewById(R.id.memory_size)).setVisibility(View.VISIBLE);
} }
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
private void renameFile(GpxInfo info) { private void renameFile(GpxInfo info) {
@ -544,7 +564,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
loadGpxAsync(info, resId == R.string.local_index_select_gpx_file); loadGpxAsync(info, resId == R.string.local_index_select_gpx_file);
} else { } else {
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true); getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
listAdapter.notifyDataSetChanged(); showOnMapGpxAdapter.addGpxInfo(info);
allGpxAdapter.notifyDataSetChanged();
selectedGpxHelper.runUiListeners(); selectedGpxHelper.runUiListeners();
} }
} else if (resId == R.string.local_index_mi_delete) { } else if (resId == R.string.local_index_mi_delete) {
@ -604,6 +626,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
e = false; e = false;
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx); getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
if (showOnMapGpxAdapter.getCount() == 0) {
setShowedOnMapVisibility(true);
}
showOnMapGpxAdapter.addGpxInfo(info);
} }
} }
if (e) { if (e) {
@ -633,37 +659,37 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true); ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
listAdapter.clear(); allGpxAdapter.clear();
if (showOnMapAdapter != null) { if (showOnMapGpxAdapter != null) {
showOnMapAdapter.clear(); showOnMapGpxAdapter.clear();
} }
} }
@Override @Override
protected void onProgressUpdate(GpxInfo... values) { protected void onProgressUpdate(GpxInfo... values) {
for (GpxInfo v : values) { for (GpxInfo v : values) {
listAdapter.addLocalIndexInfo(v); allGpxAdapter.addLocalIndexInfo(v);
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null){ if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
showOnMapAdapter.add(v); showOnMapGpxAdapter.addGpxInfo(v);
} }
} }
showOnMapAdapter.notifyDataSetChanged(); showOnMapGpxAdapter.notifyDataSetChanged();
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
public void setResult(List<GpxInfo> result) { public void setResult(List<GpxInfo> result) {
this.result = result; this.result = result;
listAdapter.clear(); allGpxAdapter.clear();
showOnMapAdapter.clear(); showOnMapGpxAdapter.clear();
if (result != null) { if (result != null) {
for (GpxInfo v : result) { for (GpxInfo v : result) {
listAdapter.addLocalIndexInfo(v); allGpxAdapter.addLocalIndexInfo(v);
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null){ if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
showOnMapAdapter.add(v); showOnMapGpxAdapter.addGpxInfo(v);
} }
} }
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
showOnMapAdapter.notifyDataSetChanged(); showOnMapGpxAdapter.notifyDataSetChanged();
onPostExecute(result); onPostExecute(result);
} }
} }
@ -674,9 +700,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (getActivity() != null) { if (getActivity() != null) {
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false); ((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
} }
if (listAdapter.getGroupCount() > 0) { if (allGpxAdapter.getGroupCount() > 0) {
getExpandableListView().expandGroup(0); getExpandableListView().expandGroup(0);
} }
if (showOnMapGpxAdapter.getCount() > 0) {
setShowedOnMapVisibility(true);
} else {
setShowedOnMapVisibility(false);
}
} }
private File[] listFilesSorted(File dir) { private File[] listFilesSorted(File dir) {
@ -1065,13 +1097,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
protected void onProgressUpdate(GpxInfo... values) { protected void onProgressUpdate(GpxInfo... values) {
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
@Override @Override
protected void onPostExecute(GpxInfo[] result) { protected void onPostExecute(GpxInfo[] result) {
hideProgressBar(); hideProgressBar();
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
@ -1101,9 +1133,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
protected void onProgressUpdate(GpxInfo... values) { protected void onProgressUpdate(GpxInfo... values) {
for (GpxInfo g : values) { for (GpxInfo g : values) {
listAdapter.delete(g); allGpxAdapter.delete(g);
} }
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
} }
@Override @Override
@ -1149,7 +1181,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
toShow = g.gpx.findPointToShow(); toShow = g.gpx.findPointToShow();
} }
} }
listAdapter.notifyDataSetInvalidated(); allGpxAdapter.notifyDataSetInvalidated();
} }
@Override @Override
@ -1201,7 +1233,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
if (info.gpx != null) { if (info.gpx != null) {
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true); getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true);
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
selectedGpxHelper.runUiListeners(); selectedGpxHelper.runUiListeners();
} }
} }
@ -1237,18 +1269,18 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
protected void publishResults(CharSequence constraint, FilterResults results) { protected void publishResults(CharSequence constraint, FilterResults results) {
if (results.values != null) { if (results.values != null) {
synchronized (listAdapter) { synchronized (allGpxAdapter) {
listAdapter.clear(); allGpxAdapter.clear();
showOnMapAdapter.clear(); showOnMapGpxAdapter.clear();
for (GpxInfo i : ((List<GpxInfo>) results.values)) { for (GpxInfo i : ((List<GpxInfo>) results.values)) {
listAdapter.addLocalIndexInfo(i); allGpxAdapter.addLocalIndexInfo(i);
if (selectedGpxHelper.getSelectedFileByName(i.getFileName()) != null){ if (selectedGpxHelper.getSelectedFileByName(i.getFileName()) != null) {
showOnMapAdapter.add(i); showOnMapGpxAdapter.addGpxInfo(i);
} }
} }
} }
showOnMapAdapter.notifyDataSetChanged(); showOnMapGpxAdapter.notifyDataSetChanged();
listAdapter.notifyDataSetChanged(); allGpxAdapter.notifyDataSetChanged();
if (constraint != null && constraint.length() > 3) { if (constraint != null && constraint.length() > 3) {
collapseTrees(10); collapseTrees(10);
} }
@ -1270,7 +1302,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override @Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
GpxInfo item = listAdapter.getChild(groupPosition, childPosition); GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition);
if (!selectionMode) { if (!selectionMode) {
item.setExpanded(!item.isExpanded()); item.setExpanded(!item.isExpanded());
if (item.isExpanded()) { if (item.isExpanded()) {
@ -1285,7 +1317,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
updateSelectionMode(actionMode); updateSelectionMode(actionMode);
} }
listAdapter.notifyDataSetInvalidated(); allGpxAdapter.notifyDataSetInvalidated();
return true; return true;
} }
@ -1394,7 +1426,39 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
} }
class ShowedOnMapAdapter extends ArrayAdapter<GpxInfo>{ private void adjustShowOnMapListViewSize() {
View v = getView();
if (v == null) {
return;
}
float size = getResources().getDimension(R.dimen.dashListItemHeight) * 3.5f;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) size);
getView().findViewById(R.id.gpx_on_map).setLayoutParams(params);
}
class ShowedOnMapAdapter extends ArrayAdapter<GpxInfo> {
public void addGpxInfo(GpxInfo info) {
boolean contains = false;
for (int i = 0; i < getCount(); i++) {
if (getItem(i).equals(info)) {
contains = true;
break;
}
}
if (contains) {
return;
}
add(info);
notifyDataSetChanged();
//if there's too many items, we need to set size of listview
if (getCount() == 4) {
adjustShowOnMapListViewSize();
}
}
public ShowedOnMapAdapter(Context context, int resource) { public ShowedOnMapAdapter(Context context, int resource) {
super(context, resource); super(context, resource);
@ -1408,7 +1472,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false); v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
} }
GpxInfo gpxInfo = getItem(position); final GpxInfo gpxInfo = getItem(position);
TextView viewName = ((TextView) v.findViewById(R.id.name)); TextView viewName = ((TextView) v.findViewById(R.id.name));
viewName.setText(gpxInfo.getName()); viewName.setText(gpxInfo.getName());
@ -1426,9 +1490,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
CompoundButton check = (CompoundButton)v.findViewById(R.id.check); final CompoundButton check = (CompoundButton) v.findViewById(R.id.check_item);
check.setVisibility(View.VISIBLE); check.setVisibility(View.VISIBLE);
if (selectedGpxHelper.getSelectedFileByName(gpxInfo.getFileName()) != null) {
check.setChecked(true);
} else {
check.setChecked(false);
}
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (gpxInfo.gpx == null) {
loadGpxAsync(gpxInfo, check.isChecked());
} else {
selectedGpxHelper.selectGpxFile(gpxInfo.gpx, check.isChecked(), true);
}
allGpxAdapter.notifyDataSetChanged();
}
});
return v; return v;
} }
} }

View file

@ -1,6 +1,5 @@
package net.osmand.plus.activities.search; package net.osmand.plus.activities.search;
import java.text.MessageFormat;
import java.util.List; import java.util.List;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -10,25 +9,18 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.Image;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.text.Spannable;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -130,10 +122,22 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
private void selectModel(final HistoryEntry model, View v) { private void selectModel(final HistoryEntry model, View v) {
PointDescription name = model.getName(); PointDescription name = model.getName();
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightContent();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings(); OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings();
DirectionsDialogs.createDirectionsActionsPopUpMenu(optionsMenu, new LatLon(model.getLat(), model.getLon()), DirectionsDialogs.createDirectionsActionsPopUpMenu(optionsMenu, new LatLon(model.getLat(), model.getLon()),
model, name, settings.getLastKnownMapZoom(), getActivity(), true); model, name, settings.getLastKnownMapZoom(), getActivity(), true);
MenuItem item = optionsMenu.getMenu().add(
R.string.edit_filter_delete_menu_item).setIcon(light ?
R.drawable.ic_action_delete_light : R.drawable.ic_action_delete_dark);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
helper.remove(model);
historyAdapter.remove(model);
return true;
}
});
optionsMenu.show(); optionsMenu.show();
} }