From 124e445e63c0239735ca4af8a835d93f29e097a7 Mon Sep 17 00:00:00 2001 From: alexzatsepin Date: Thu, 15 Sep 2016 02:12:15 +0300 Subject: [PATCH] [android] Added size of altitude chart panel processing depending on route type (the altitude image is not diplayed for vehicle route) --- .../src/com/mapswithme/maps/MwmActivity.java | 7 ++--- .../maps/routing/RoutingController.java | 4 +-- .../maps/routing/RoutingPlanController.java | 30 +++++++++++++++---- .../maps/routing/RoutingPlanFragment.java | 4 +-- .../routing/RoutingPlanInplaceController.java | 12 ++------ 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index f840491929..c855914954 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -1345,17 +1345,16 @@ public class MwmActivity extends BaseMwmFragmentActivity } @Override - public void onRouteBuilt() { - mLogger.d("onRouteBuilt"); + public void onRouteBuilt(@Framework.RouterType int router) { if (mIsFragmentContainer) { RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class); if (fragment != null) - fragment.showRouteAltitudeChart(); + fragment.showRouteAltitudeChart(router != Framework.ROUTER_TYPE_VEHICLE); } else { - mRoutingPlanInplaceController.showRouteAltitudeChart(); + mRoutingPlanInplaceController.showRouteAltitudeChart(router != Framework.ROUTER_TYPE_VEHICLE); } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index 86290dc15a..d15c4a649d 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -63,7 +63,7 @@ public class RoutingController void showDownloader(boolean openDownloaded); void updateMenu(); void updatePoints(); - void onRouteBuilt(); + void onRouteBuilt(@Framework.RouterType int router); /** * @param progress progress to be displayed. @@ -116,7 +116,7 @@ public class RoutingController mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo(); setBuildState(BuildState.BUILT); mLastBuildProgress = 100; - mContainer.onRouteBuilt(); + mContainer.onRouteBuilt(mLastRouterType); } processRoutingEvent(); diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java index 6b345fd9f0..2a05e60ae7 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java @@ -291,6 +291,11 @@ public class RoutingPlanController extends ToolbarController } } + protected boolean isVehicleRouteChecked() + { + return mRouterTypes.getCheckedRadioButtonId() == R.id.vehicle; + } + public void disableToggle() { UiUtils.hide(mToggle); @@ -302,15 +307,28 @@ public class RoutingPlanController extends ToolbarController return mOpen; } - public void showRouteAltitudeChart() + public void showRouteAltitudeChart(boolean show) { ImageView altitudeChart = (ImageView) mFrame.findViewById(R.id.altitude_chart); - int chartWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_width); - int chartHeight = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_height); - Bitmap bm = Framework.GenerateRouteAltitudeChart(chartWidth, chartHeight); - if (bm != null) + showRouteAltitudeChartInternal(show, altitudeChart); + } + + protected void showRouteAltitudeChartInternal(boolean show, ImageView altitudeChart) + { + if (show) { - altitudeChart.setImageBitmap(bm); + int chartWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_width); + int chartHeight = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_height); + Bitmap bm = Framework.GenerateRouteAltitudeChart(chartWidth, chartHeight); + if (bm != null) + { + altitudeChart.setImageBitmap(bm); + altitudeChart.setVisibility(View.VISIBLE); + } + } + else + { + altitudeChart.setVisibility(View.GONE); } } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java index e7469768da..2389c32373 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java @@ -70,8 +70,8 @@ public class RoutingPlanFragment extends BaseMwmFragment return RoutingController.get().cancelPlanning(); } - public void showRouteAltitudeChart() + public void showRouteAltitudeChart(boolean show) { - mPlanController.showRouteAltitudeChart(); + mPlanController.showRouteAltitudeChart(show); } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java index 47845a60ee..d1d1b80761 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java @@ -93,20 +93,14 @@ public class RoutingPlanInplaceController extends RoutingPlanController mSlotsRestoredState = state.getBoolean(STATE_OPEN); if (state.getBoolean(STATE_ALTITUDE_CHART_SHOWN)) - showRouteAltitudeChart(); + showRouteAltitudeChart(!isVehicleRouteChecked()); } @Override - public void showRouteAltitudeChart() + public void showRouteAltitudeChart(boolean show) { ImageView altitudeChart = (ImageView) mActivity.findViewById(R.id.altitude_chart); - int chartWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_width); - int chartHeight = mActivity.getResources().getDimensionPixelSize(R.dimen.altitude_chart_image_height); - Bitmap bm = Framework.GenerateRouteAltitudeChart(chartWidth, chartHeight); - if (bm != null) - { - altitudeChart.setImageBitmap(bm); - } + showRouteAltitudeChartInternal(show, altitudeChart); } }