Fix TrackActivity crash

This commit is contained in:
Alexey Kulish 2017-07-26 15:58:35 +03:00
parent 92d5ced23c
commit e54028e818

View file

@ -121,16 +121,16 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
return view;
}
public TrackActivity getMyActivity() {
public TrackActivity getTrackActivity() {
return (TrackActivity) getActivity();
}
private GPXFile getGpx() {
return getMyActivity().getGpx();
return getTrackActivity().getGpx();
}
private GpxDataItem getGpxDataItem() {
return getMyActivity().getGpxDataItem();
return getTrackActivity().getGpxDataItem();
}
private void expandAllGroups() {
@ -160,8 +160,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
}
private List<GpxDisplayGroup> filterGroups() {
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(false);
List<GpxDisplayGroup> groups = new ArrayList<>();
if (getTrackActivity() != null) {
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(false);
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
@ -181,6 +182,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
}
}
}
return groups;
}
@ -537,8 +539,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
private void selectFavoritesImpl() {
if (!selectedItems.isEmpty()) {
AlertDialog.Builder b = new AlertDialog.Builder(getMyActivity());
final EditText editText = new EditText(getMyActivity());
AlertDialog.Builder b = new AlertDialog.Builder(getTrackActivity());
final EditText editText = new EditText(getTrackActivity());
String name = selectedItems.iterator().next().group.getName();
if(name.indexOf('\n') > 0) {
name = name.substring(0, name.indexOf('\n'));
@ -818,7 +820,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
groupColor = gpxItem.locationStart.getColor(groupColor);
}
if (groupColor == 0) {
groupColor = getMyActivity().getResources().getColor(R.color.gpx_color_point);
groupColor = getTrackActivity().getResources().getColor(R.color.gpx_color_point);
}
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false));
} else {