From 430d3c081f84beeb1cfdcae2fc2a0ca6443f00d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Mon, 3 Jul 2017 12:40:18 +0300 Subject: [PATCH] [android] Added EMPTY check for taxi types --- android/jni/com/mapswithme/maps/UserMarkHelper.cpp | 4 ++++ android/jni/com/mapswithme/maps/taxi/TaxiManager.cpp | 5 ++--- .../src/com/mapswithme/maps/bookmarks/data/MapObject.java | 4 ++-- android/src/com/mapswithme/maps/taxi/TaxiAdapter.java | 2 +- .../com/mapswithme/maps/widget/placepage/PlacePageView.java | 3 +-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/android/jni/com/mapswithme/maps/UserMarkHelper.cpp b/android/jni/com/mapswithme/maps/UserMarkHelper.cpp index d1b2fe129b..3f183c3d7d 100644 --- a/android/jni/com/mapswithme/maps/UserMarkHelper.cpp +++ b/android/jni/com/mapswithme/maps/UserMarkHelper.cpp @@ -167,7 +167,11 @@ jobjectArray ToBannersArray(JNIEnv * env, vector const & banners) jintArray ToReachableByTaxiProvidersArray(JNIEnv * env, vector const & types) { + if (types.size() == 0) + return nullptr; + jintArray result = env->NewIntArray(types.size()); + ASSERT(result, ()); jint tmp[types.size()]; for (int i = 0; i < types.size(); i++) diff --git a/android/jni/com/mapswithme/maps/taxi/TaxiManager.cpp b/android/jni/com/mapswithme/maps/taxi/TaxiManager.cpp index 1df6605adc..60ec177ca5 100644 --- a/android/jni/com/mapswithme/maps/taxi/TaxiManager.cpp +++ b/android/jni/com/mapswithme/maps/taxi/TaxiManager.cpp @@ -1,7 +1,6 @@ -#include "../Framework.hpp" - -#include "com/mapswithme/core/jni_helper.hpp" #include "com/mapswithme/maps/Framework.hpp" +#include "com/mapswithme/core/jni_helper.hpp" + #include "partners_api/taxi_provider.hpp" namespace diff --git a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java index 78d8f9af9d..a42ea92d31 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java @@ -62,7 +62,7 @@ public class MapObject implements Parcelable public MapObject(@NonNull String mwmName, long mwmVersion, int featureIndex, @MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle, String subtitle, String address, double lat, double lon, String apiId, - @Nullable Banner[] banners, @TaxiManager.TaxiType int[] types, + @Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] types, @Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo, @Nullable RoutePointInfo routePointInfo) { @@ -74,7 +74,7 @@ public class MapObject implements Parcelable public MapObject(@NonNull String mwmName, long mwmVersion, int featureIndex, @MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle, String subtitle, String address, double lat, double lon, Metadata metadata, - String apiId, @Nullable Banner[] banners, @TaxiManager.TaxiType int[] taxiTypes, + String apiId, @Nullable Banner[] banners, @Nullable @TaxiManager.TaxiType int[] taxiTypes, @Nullable String bookingSearchUrl, @Nullable LocalAdInfo localAdInfo, @Nullable RoutePointInfo routePointInfo) { diff --git a/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java index 94464c9e0f..2105d52cc3 100644 --- a/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java +++ b/android/src/com/mapswithme/maps/taxi/TaxiAdapter.java @@ -51,7 +51,7 @@ public class TaxiAdapter extends PagerAdapter View v = LayoutInflater.from(mContext).inflate(R.layout.taxi_pager_item, container, false); TextView name = (TextView) v.findViewById(R.id.product_name); // We ignore all Yandex.Taxi product names until they do support of passing product parameters - // to their app vie deeplink. + // to their app via deeplink. if (mType == TaxiManager.PROVIDER_YANDEX) name.setText(R.string.yandex_taxi_title); else diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 1fbbb83d13..c52178828d 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -1313,10 +1313,9 @@ public class PlacePageView extends RelativeLayout if (!showTaxiOffer) return; - List types = mapObject.getReachableByTaxiTypes(); // At this moment we display only a one taxi provider at the same time. @TaxiManager.TaxiType - int type = types.get(0); + int type = taxiTypes.get(0); UiUtils.showTaxiIcon((ImageView) mTaxi.findViewById(R.id.iv__place_page_taxi), type); UiUtils.showTaxiTitle((TextView) mTaxi.findViewById(R.id.tv__place_page_taxi), type); Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_SHOW_IN_PP, type);