From e95f4bd282dd746767aed9489f78f8f21006bfc3 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 9 Aug 2017 15:34:00 +0300 Subject: [PATCH] Add some changes --- .../res/layout/fragment_measurement_tool.xml | 4 +- .../MeasurementToolFragment.java | 45 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/OsmAnd/res/layout/fragment_measurement_tool.xml b/OsmAnd/res/layout/fragment_measurement_tool.xml index e5e9b0a53b..79fe3f4b35 100644 --- a/OsmAnd/res/layout/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout/fragment_measurement_tool.xml @@ -90,13 +90,13 @@ android:background="@color/ctx_menu_info_view_bg_dark" android:visibility="gone"> - - + + 0) { - showPointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down)); + showPointsList(); } else { - hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up)); + hidePointsList(); } } }); - final ImageButton undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button)); - final ImageButton redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button)); + undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button)); + redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button)); undoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark)); undoBtn.setOnClickListener(new View.OnClickListener() { @@ -136,7 +145,7 @@ public class MeasurementToolFragment extends Fragment { enable(undoBtn); } else { disable(undoBtn, upDownBtn); - hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up)); + hidePointsList(); } adapter.notifyDataSetChanged(); enable(redoBtn); @@ -163,14 +172,14 @@ public class MeasurementToolFragment extends Fragment { mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - addPoint(undoBtn, upDownBtn, redoBtn); + addPoint(); } }); measurementLayer.setOnSingleTapListener(new MeasurementToolLayer.OnSingleTapListener() { @Override public void onSingleTap() { - addPoint(undoBtn, upDownBtn, redoBtn); + addPoint(); } }); @@ -223,7 +232,7 @@ public class MeasurementToolFragment extends Fragment { return true; case R.id.action_clear_all: measurementLayer.clearPoints(); - hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up)); + hidePointsList(); disable(undoBtn, redoBtn, upDownBtn); updateText(); commandManager.clear(); @@ -254,7 +263,7 @@ public class MeasurementToolFragment extends Fragment { disable(redoBtn); updateText(); if (measurementLayer.getPointsCount() < 1) { - hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up)); + hidePointsList(); disable(upDownBtn); if (!commandManager.canUndo()) { disable(undoBtn); @@ -290,7 +299,7 @@ public class MeasurementToolFragment extends Fragment { return view; } - private void addPoint(View undoBtn, View upDownBtn, View redoBtn) { + private void addPoint() { MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { commandManager.execute(new AddPointCommand(measurementLayer)); @@ -301,10 +310,10 @@ public class MeasurementToolFragment extends Fragment { } } - private void showPointsList(View view, Drawable icon) { + private void showPointsList() { pointsListOpened = true; - view.findViewById(R.id.points_list_container).setVisibility(View.VISIBLE); - ((ImageView) view.findViewById(R.id.up_down_button)).setImageDrawable(icon); + pointsListContainer.setVisibility(View.VISIBLE); + upDownBtn.setImageDrawable(downIcon); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { OsmandMapTileView tileView = mapActivity.getMapView(); @@ -314,10 +323,10 @@ public class MeasurementToolFragment extends Fragment { } } - private void hidePointsList(View view, Drawable icon) { + private void hidePointsList() { pointsListOpened = false; - view.findViewById(R.id.points_list_container).setVisibility(View.GONE); - ((ImageView) view.findViewById(R.id.up_down_button)).setImageDrawable(icon); + pointsListContainer.setVisibility(View.GONE); + upDownBtn.setImageDrawable(upIcon); setPreviousMapPosition(); }