This commit is contained in:
PavelRatushny 2017-08-11 13:30:52 +03:00
parent 145ee2d096
commit 5796d5f2e0
2 changed files with 86 additions and 64 deletions

View file

@ -139,18 +139,15 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
overlayView.setVisibility(View.VISIBLE);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.track_points_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
setHasOptionsMenu(true);
overlayView = view.findViewById(R.id.overlay_view);
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(new View.OnClickListener() {
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overlay_view:
hideTransparentOverlay();
closeMenu();
break;
case R.id.menu_fab:
if (menuOpened) {
hideTransparentOverlay();
closeMenu();
@ -158,37 +155,51 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
showTransparentOverlay();
openMenu();
}
break;
case R.id.waypoint_text_layout:
case R.id.waypoint_fab:
PointDescription pointWptDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointWptDescription);
break;
case R.id.route_text_layout:
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
case R.id.line_text_layout:
case R.id.line_fab:
addLine();
break;
}
});
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.track_points_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
setHasOptionsMenu(true);
overlayView = view.findViewById(R.id.overlay_view);
overlayView.setOnClickListener(onFabClickListener);
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(onFabClickListener);
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointDescription);
}
});
waypointFab.setOnClickListener(onFabClickListener);
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
waypointTextLayout.setOnClickListener(onFabClickListener);
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
routePointFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointDescription);
}
});
routePointFab.setOnClickListener(onFabClickListener);
routePointTextLayout = view.findViewById(R.id.route_text_layout);
routePointTextLayout.setOnClickListener(onFabClickListener);
lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab);
lineFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addLine();
}
});
lineFab.setOnClickListener(onFabClickListener);
lineTextLayout = view.findViewById(R.id.line_text_layout);
lineTextLayout.setOnClickListener(onFabClickListener);
TextView tv = new TextView(getActivity());
tv.setText(R.string.none_selected_gpx);

View file

@ -189,6 +189,41 @@ public class TrackSegmentFragment extends OsmAndListFragment {
overlayView.setVisibility(View.VISIBLE);
}
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overlay_view:
hideTransparentOverlay();
closeMenu();
break;
case R.id.menu_fab:
if (menuOpened) {
hideTransparentOverlay();
closeMenu();
} else {
showTransparentOverlay();
openMenu();
}
break;
case R.id.waypoint_text_layout:
case R.id.waypoint_fab:
PointDescription pointWptDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointWptDescription);
break;
case R.id.route_text_layout:
case R.id.route_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
case R.id.line_text_layout:
case R.id.line_fab:
addLine();
break;
}
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
@ -204,49 +239,25 @@ public class TrackSegmentFragment extends OsmAndListFragment {
listView.setEmptyView(tv);
overlayView = view.findViewById(R.id.overlay_view);
overlayView.setOnClickListener(onFabClickListener);
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
menuFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (menuOpened) {
hideTransparentOverlay();
closeMenu();
} else {
showTransparentOverlay();
openMenu();
}
}
});
menuFab.setOnClickListener(onFabClickListener);
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointDescription);
}
});
waypointFab.setOnClickListener(onFabClickListener);
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
waypointTextLayout.setOnClickListener(onFabClickListener);
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
routePointFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointDescription);
}
});
routePointFab.setOnClickListener(onFabClickListener);
routePointTextLayout = view.findViewById(R.id.route_text_layout);
routePointTextLayout.setOnClickListener(onFabClickListener);
lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab);
lineFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addLine();
}
});
lineFab.setOnClickListener(onFabClickListener);
lineTextLayout = view.findViewById(R.id.line_text_layout);
lineTextLayout.setOnClickListener(onFabClickListener);
paint = new Paint();
paint.setStyle(Paint.Style.STROKE);