refactored some code

This commit is contained in:
Chumva 2018-03-27 19:14:07 +03:00
parent 6526c48da7
commit c93f20e11d

View file

@ -155,8 +155,8 @@ public class TrackSegmentFragment extends OsmAndListFragment {
private FloatingActionButton lineFab; private FloatingActionButton lineFab;
private View lineTextLayout; private View lineTextLayout;
private View overlayView; private View overlayView;
private IconPopupMenu iconGeneralPopupMenu; private IconPopupMenu generalPopupMenu;
private IconPopupMenu iconAltitudePopupMenu; private IconPopupMenu altitudePopupMenu;
private ListPopupWindow splitListPopupWindow; private ListPopupWindow splitListPopupWindow;
private ListPopupWindow colorListPopupWindow; private ListPopupWindow colorListPopupWindow;
@ -411,8 +411,8 @@ public class TrackSegmentFragment extends OsmAndListFragment {
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
updateEnable = false; updateEnable = false;
if (iconGeneralPopupMenu != null) { if (generalPopupMenu != null) {
iconGeneralPopupMenu.dismiss(); generalPopupMenu.dismiss();
} }
if (splitListPopupWindow != null) { if (splitListPopupWindow != null) {
splitListPopupWindow.dismiss(); splitListPopupWindow.dismiss();
@ -420,8 +420,8 @@ public class TrackSegmentFragment extends OsmAndListFragment {
if (colorListPopupWindow != null) { if (colorListPopupWindow != null) {
colorListPopupWindow.dismiss(); colorListPopupWindow.dismiss();
} }
if (iconAltitudePopupMenu != null) { if (altitudePopupMenu != null) {
iconAltitudePopupMenu.dismiss(); altitudePopupMenu.dismiss();
} }
} }
@ -1369,12 +1369,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
iconGeneralPopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu)); generalPopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
Menu menu = iconGeneralPopupMenu.getMenu(); Menu menu = generalPopupMenu.getMenu();
iconGeneralPopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu); generalPopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark)); menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark)); menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
iconGeneralPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() { generalPopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -1406,7 +1406,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
return false; return false;
} }
}); });
iconGeneralPopupMenu.show(); generalPopupMenu.show();
} }
}); });
} else { } else {
@ -1472,12 +1472,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.overflow_menu).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
iconAltitudePopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu)); altitudePopupMenu = new IconPopupMenu(getTrackActivity(), view.findViewById(R.id.overflow_menu));
Menu menu = iconAltitudePopupMenu.getMenu(); Menu menu = altitudePopupMenu.getMenu();
iconAltitudePopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu); altitudePopupMenu.getMenuInflater().inflate(R.menu.track_segment_menu, menu);
menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark)); menu.findItem(R.id.action_edit).setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark));
menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark)); menu.findItem(R.id.action_delete).setIcon(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
iconAltitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() { altitudePopupMenu.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -1500,7 +1500,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
return false; return false;
} }
}); });
iconAltitudePopupMenu.show(); altitudePopupMenu.show();
} }
}); });
} else { } else {