From 4b0adf4aa8fb9127b2c48b8fd1df3405e633f1a5 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: Fri, 6 Sep 2019 16:28:57 +0300 Subject: [PATCH] [android] Added raw types to map object --- .../com/mapswithme/maps/UserMarkHelper.cpp | 21 +++++++----- .../maps/bookmarks/data/Bookmark.java | 5 +-- .../maps/bookmarks/data/MapObject.java | 34 ++++++++++++++----- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/android/jni/com/mapswithme/maps/UserMarkHelper.cpp b/android/jni/com/mapswithme/maps/UserMarkHelper.cpp index bbdfd8048f..bdc51a8e5c 100644 --- a/android/jni/com/mapswithme/maps/UserMarkHelper.cpp +++ b/android/jni/com/mapswithme/maps/UserMarkHelper.cpp @@ -78,7 +78,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion bool shouldShowUGC, bool canBeRated, bool canBeReviewed, jobjectArray jratings, jobject const & hotelType, int priceRate, jobject const & popularity, string const & description, - RoadWarningMarkType roadWarningMarkType) + RoadWarningMarkType roadWarningMarkType, jobjectArray jrawTypes) { // public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, String title, // @Nullable String secondaryTitle, String subtitle, String address, @@ -97,7 +97,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion "Lcom/mapswithme/maps/ads/LocalAdInfo;" "Lcom/mapswithme/maps/routing/RoutePointInfo;IZZZ[Lcom/mapswithme/maps/ugc/UGC$Rating;" "Lcom/mapswithme/maps/search/HotelsFilter$HotelType;ILcom/mapswithme/maps/search/Popularity;" - "Ljava/lang/String;I)V"); + "Ljava/lang/String;I[Ljava/lang/String;)V"); //public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex) static jmethodID const featureCtorId = @@ -121,7 +121,7 @@ jobject CreateMapObject(JNIEnv * env, string const & mwmName, int64_t mwmVersion static_cast(openingMode), static_cast(shouldShowUGC), static_cast(canBeRated), static_cast(canBeReviewed), jratings, hotelType, priceRate, popularity, jDescription.get(), - static_cast(roadWarningMarkType)); + static_cast(roadWarningMarkType), jrawTypes); InjectMetadata(env, g_mapObjectClazz, mapObject, metadata); return mapObject; @@ -137,6 +137,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) jni::TScopedLocalIntArrayRef jTaxiTypes(env, ToReachableByTaxiProvidersArray(env, info.ReachableByTaxiProviders())); + jni::TScopedLocalObjectArrayRef jrawTypes(env, jni::ToJavaStringArray(env, info.GetRawTypes())); + jni::TScopedLocalRef localAdInfo(env, CreateLocalAdInfo(env, info)); jni::TScopedLocalRef routingPointInfo(env, nullptr); @@ -170,7 +172,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) "Lcom/mapswithme/maps/routing/RoutePointInfo;" "IZZZ[Lcom/mapswithme/maps/ugc/UGC$Rating;" "Lcom/mapswithme/maps/search/HotelsFilter$HotelType;" - "ILcom/mapswithme/maps/search/Popularity;Ljava/lang/String;)V"); + "ILcom/mapswithme/maps/search/Popularity;Ljava/lang/String;" + "[Ljava/lang/String;)V"); // public FeatureId(@NonNull String mwmName, long mwmVersion, int featureIndex) static jmethodID const featureCtorId = jni::GetConstructorID(env, g_featureIdClazz, "(Ljava/lang/String;JI)V"); @@ -193,7 +196,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) jAddress.get(), jbanners.get(), jTaxiTypes.get(), jBookingSearchUrl.get(), localAdInfo.get(), routingPointInfo.get(), info.GetOpeningMode(), info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate, - popularity.get(), jDescription.get(), info.GetRoadType()); + popularity.get(), jDescription.get(), jrawTypes.get()); if (info.IsFeature()) InjectMetadata(env, g_mapObjectClazz, mapObject, info.GetMetadata()); @@ -212,7 +215,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.GetOpeningMode(), info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate, - popularity.get(), info.GetDescription(), info.GetRoadType()); + popularity.get(), info.GetDescription(), info.GetRoadType(), + jrawTypes.get()); } if (info.HasApiUrl()) @@ -223,7 +227,8 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) info.GetAddress(), info.GetMetadata(), info.GetApiUrl(), jbanners.get(), jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.GetOpeningMode(), info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(), jratings.get(), - hotelType.get(), priceRate, popularity.get(), info.GetDescription(), info.GetRoadType()); + hotelType.get(), priceRate, popularity.get(), info.GetDescription(), info.GetRoadType(), + jrawTypes.get()); } return CreateMapObject( @@ -233,7 +238,7 @@ jobject CreateMapObject(JNIEnv * env, place_page::Info const & info) jTaxiTypes.get(), info.GetBookingSearchUrl(), localAdInfo.get(), routingPointInfo.get(), info.GetOpeningMode(), info.ShouldShowUGC(), info.CanBeRated(), info.CanBeReviewed(), jratings.get(), hotelType.get(), priceRate, popularity.get(), - info.GetDescription(), info.GetRoadType()); + info.GetDescription(), info.GetRoadType(), jrawTypes.get()); } jobjectArray ToBannersArray(JNIEnv * env, vector const & banners) diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java index b0624bc166..88ce9b5f58 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java @@ -34,12 +34,13 @@ public class Bookmark extends MapObject @OpeningMode int openingMode, boolean shouldShowUGC, boolean canBeRated, boolean canBeReviewed, @Nullable UGC.Rating[] ratings, @Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate, - @NonNull Popularity popularity, @NonNull String description) + @NonNull Popularity popularity, @NonNull String description, + @Nullable String[] rawTypes) { super(featureId, BOOKMARK, title, secondaryTitle, subtitle, address, 0, 0, "", banners, reachableByTaxiTypes, bookingSearchUrl, localAdInfo, routePointInfo, openingMode, shouldShowUGC, canBeRated, canBeReviewed, ratings, hotelType, priceRate, - popularity, description, RoadWarningMarkType.UNKNOWN.ordinal()); + popularity, description, RoadWarningMarkType.UNKNOWN.ordinal(), rawTypes); mCategoryId = categoryId; mBookmarkId = bookmarkId; diff --git a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java index de0a6ce162..f109342f5d 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java @@ -89,6 +89,8 @@ public class MapObject implements Parcelable, PopularityProvider private HotelsFilter.HotelType mHotelType; @PriceFilterView.PriceDef private final int mPriceRate; + @Nullable + private List mRawTypes; public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, String title, @Nullable String secondaryTitle, String subtitle, String address, @@ -98,12 +100,14 @@ public class MapObject implements Parcelable, PopularityProvider @OpeningMode int openingMode, boolean shouldShowUGC, boolean canBeRated, boolean canBeReviewed, @Nullable UGC.Rating[] ratings, @Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate, - @NonNull Popularity popularity, @NonNull String description, int roadWarningType) + @NonNull Popularity popularity, @NonNull String description, int roadWarningType, + @Nullable String[] rawTypes) { this(featureId, mapObjectType, title, secondaryTitle, subtitle, address, lat, lon, new Metadata(), apiId, banners, types, bookingSearchUrl, localAdInfo, routePointInfo, openingMode, shouldShowUGC, - canBeRated, canBeReviewed, ratings, hotelType, priceRate, popularity, description, roadWarningType); + canBeRated, canBeReviewed, ratings, hotelType, priceRate, popularity, description, + roadWarningType, rawTypes); } public MapObject(@NonNull FeatureId featureId, @MapObjectType int mapObjectType, @@ -115,7 +119,7 @@ public class MapObject implements Parcelable, PopularityProvider boolean shouldShowUGC, boolean canBeRated, boolean canBeReviewed, @Nullable UGC.Rating[] ratings, @Nullable HotelsFilter.HotelType hotelType, @PriceFilterView.PriceDef int priceRate, @NonNull Popularity popularity, - @NonNull String description, int roadWarningType) + @NonNull String description, int roadWarningType, @Nullable String[] rawTypes) { mFeatureId = featureId; mMapObjectType = mapObjectType; @@ -149,6 +153,8 @@ public class MapObject implements Parcelable, PopularityProvider mHotelType = hotelType; mPriceRate = priceRate; mRoadWarningMarkType = RoadWarningMarkType.values()[roadWarningType]; + if (rawTypes != null) + mRawTypes = new ArrayList<>(Arrays.asList(rawTypes)); } protected MapObject(@MapObjectType int type, Parcel source) @@ -175,15 +181,18 @@ public class MapObject implements Parcelable, PopularityProvider source.readInt() == 1, // mCanBeReviewed null, // mRatings source.readParcelable(HotelsFilter.HotelType.class.getClassLoader()), // mHotelType + source.readInt(), // mPriceRate source.readParcelable(Popularity.class.getClassLoader()), source.readString(), - source.readInt() + source.readInt(), + null // mRawTypes ); mBanners = readBanners(source); mReachableByTaxiTypes = readTaxiTypes(source); mRatings = readRatings(source); + mRawTypes = readRawTypes(source); } @NonNull @@ -196,11 +205,11 @@ public class MapObject implements Parcelable, PopularityProvider false /* shouldShowUGC */, false /* canBeRated */, false /* canBeReviewed */, null /* ratings */, null /* mHotelType */, PriceFilterView.UNDEFINED, Popularity.defaultInstance(), "", - RoadWarningMarkType.UNKNOWN.ordinal()); + RoadWarningMarkType.UNKNOWN.ordinal(), new String[0]); } @Nullable - private List readBanners(@NonNull Parcel source) + private static List readBanners(@NonNull Parcel source) { List banners = new ArrayList<>(); source.readTypedList(banners, Banner.CREATOR); @@ -208,7 +217,7 @@ public class MapObject implements Parcelable, PopularityProvider } @Nullable - private ArrayList readRatings(@NonNull Parcel source) + private static ArrayList readRatings(@NonNull Parcel source) { ArrayList ratings = new ArrayList<>(); source.readTypedList(ratings, UGC.Rating.CREATOR); @@ -216,13 +225,21 @@ public class MapObject implements Parcelable, PopularityProvider } @NonNull - private List readTaxiTypes(@NonNull Parcel source) + private static List readTaxiTypes(@NonNull Parcel source) { List types = new ArrayList<>(); source.readList(types, TaxiType.class.getClassLoader()); return types; } + @NonNull + private static List readRawTypes(@NonNull Parcel source) + { + List types = new ArrayList<>(); + source.readStringList(types); + return types; + } + /** * If you override {@link #equals(Object)} it is also required to override {@link #hashCode()}. * MapObject does not participate in any sets or other collections that need {@code hashCode()}. @@ -492,6 +509,7 @@ public class MapObject implements Parcelable, PopularityProvider dest.writeTypedList(mBanners); dest.writeList(mReachableByTaxiTypes); dest.writeTypedList(mRatings); + dest.writeStringList(mRawTypes); } @Override