[promo] protocol is changed. Gallery category is added

This commit is contained in:
Arsentiy Milchakov 2019-09-12 16:44:00 +03:00 committed by Aleksandr Zatsepin
parent f6824d4ba1
commit d7ed8474e2
4 changed files with 17 additions and 7 deletions

View file

@ -39,7 +39,7 @@ void PrepareClassRefs(JNIEnv * env)
g_galleryConstructor =
jni::GetConstructorID(env, g_galleryClass,
"([Lcom/mapswithme/maps/promo/PromoCityGallery$Item;"
"Ljava/lang/String;)V");
"Ljava/lang/String;Ljava/lang/String;)V");
g_itemClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/promo/PromoCityGallery$Item");
g_itemConstructor =
jni::GetConstructorID(env, g_itemClass,
@ -136,8 +136,10 @@ jobject MakeCityGallery(JNIEnv * env, promo::CityGallery const & gallery)
jni::TScopedLocalObjectArrayRef items(env, jni::ToJavaArray(env, g_itemClass, gallery.m_items,
itemBuilder));
jni::TScopedLocalRef moreUrl(env, jni::ToJavaString(env, gallery.m_moreUrl));
jni::TScopedLocalRef category(env, jni::ToJavaString(env, gallery.m_category));
return env->NewObject(g_galleryClass, g_galleryConstructor, items.get(), moreUrl.get());
return env->NewObject(g_galleryClass, g_galleryConstructor, items.get(), moreUrl.get(),
category.get());
}
}

View file

@ -11,11 +11,14 @@ public final class PromoCityGallery
private final Item[] mItems;
@NonNull
private final String mMoreUrl;
@NonNull
private final String mCategory;
PromoCityGallery(@NonNull Item[] items, @NonNull String moreUrl)
PromoCityGallery(@NonNull Item[] items, @NonNull String moreUrl, @NonNull String category)
{
mItems = items;
mMoreUrl = moreUrl;
mCategory = category;
}
@NonNull
@ -30,6 +33,12 @@ public final class PromoCityGallery
return mMoreUrl;
}
@NonNull
public String getCategory()
{
return mCategory;
}
public static final class Item
{
@NonNull

View file

@ -87,11 +87,9 @@ void ParseCityGallery(std::string const & src, UTM utm, promo::CityGallery & res
}
auto const meta = json_object_get(root.get(), "meta");
// Workaround, should be changed to optional field when server will be done.
auto const more = json_object_get(meta, "more");
if (json_is_string(more))
FromJSON(more, result.m_moreUrl);
FromJSONObjectOptionalField(meta, "more", result.m_moreUrl);
result.m_moreUrl = InjectUTM(url::Join(BOOKMARKS_CATALOG_FRONT_URL, result.m_moreUrl), utm);
FromJSONObjectOptionalField(meta, "category", result.m_category);
}
std::string ToSignedId(std::string const & id)

View file

@ -54,6 +54,7 @@ struct CityGallery
}
std::string m_moreUrl;
std::string m_category;
std::vector<Item> m_items;
};