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); overlayView.setVisibility(View.VISIBLE);
} }
@Override private View.OnClickListener onFabClickListener = new View.OnClickListener() {
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() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) {
case R.id.overlay_view:
hideTransparentOverlay();
closeMenu();
break;
case R.id.menu_fab:
if (menuOpened) { if (menuOpened) {
hideTransparentOverlay(); hideTransparentOverlay();
closeMenu(); closeMenu();
@ -158,37 +155,51 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
showTransparentOverlay(); showTransparentOverlay();
openMenu(); 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 = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
waypointFab.setOnClickListener(new View.OnClickListener() { waypointFab.setOnClickListener(onFabClickListener);
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
addPoint(pointDescription);
}
});
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout); waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
waypointTextLayout.setOnClickListener(onFabClickListener);
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab); routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
routePointFab.setOnClickListener(new View.OnClickListener() { routePointFab.setOnClickListener(onFabClickListener);
@Override
public void onClick(View view) {
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointDescription);
}
});
routePointTextLayout = view.findViewById(R.id.route_text_layout); routePointTextLayout = view.findViewById(R.id.route_text_layout);
routePointTextLayout.setOnClickListener(onFabClickListener);
lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab); lineFab = (FloatingActionButton) view.findViewById(R.id.line_fab);
lineFab.setOnClickListener(new View.OnClickListener() { lineFab.setOnClickListener(onFabClickListener);
@Override
public void onClick(View view) {
addLine();
}
});
lineTextLayout = view.findViewById(R.id.line_text_layout); lineTextLayout = view.findViewById(R.id.line_text_layout);
lineTextLayout.setOnClickListener(onFabClickListener);
TextView tv = new TextView(getActivity()); TextView tv = new TextView(getActivity());
tv.setText(R.string.none_selected_gpx); tv.setText(R.string.none_selected_gpx);

View file

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