Create fabOnClickListener

This commit is contained in:
PavelRatushny 2017-08-08 13:41:51 +03:00
parent 59ed65326e
commit c5bc873de4
2 changed files with 60 additions and 60 deletions

View file

@ -130,6 +130,32 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
: R.color.ctx_menu_info_view_bg_dark)); : R.color.ctx_menu_info_view_bg_dark));
} }
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.menu_fab:
if (menuOpened) {
closeMenu();
} else {
openMenu();
}
break;
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_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
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) {
View view = inflater.inflate(R.layout.points_tree, container, false); View view = inflater.inflate(R.layout.points_tree, container, false);
@ -137,44 +163,18 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
setHasOptionsMenu(true); setHasOptionsMenu(true);
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) {
closeMenu();
} else {
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);
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);
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);
TextView tv = new TextView(getActivity()); TextView tv = new TextView(getActivity());

View file

@ -179,6 +179,32 @@ public class TrackSegmentFragment extends OsmAndListFragment {
: R.color.ctx_menu_info_view_bg_dark)); : R.color.ctx_menu_info_view_bg_dark));
} }
private View.OnClickListener onFabClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.menu_fab:
if (menuOpened) {
closeMenu();
} else {
openMenu();
}
break;
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_fab:
PointDescription pointRteDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
addPoint(pointRteDescription);
break;
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);
@ -194,44 +220,18 @@ public class TrackSegmentFragment extends OsmAndListFragment {
listView.setEmptyView(tv); listView.setEmptyView(tv);
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) {
closeMenu();
} else {
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);
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);
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);
paint = new Paint(); paint = new Paint();