Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp12
-rw-r--r--android/jni/com/mapswithme/maps/Framework.hpp6
-rw-r--r--android/jni/com/mapswithme/maps/UGC.cpp13
-rw-r--r--ugc/api.cpp12
4 files changed, 22 insertions, 21 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index e96baf3755..0a6456b4cb 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -275,6 +275,8 @@ Storage & Framework::GetStorage()
return m_work.GetStorage();
}
+Index const & Framework::GetIndex() { return m_work.GetIndex(); }
+
void Framework::ShowNode(TCountryId const & idx, bool zoomToDownloadButton)
{
if (zoomToDownloadButton)
@@ -578,15 +580,9 @@ void Framework::RequestViatorProducts(JNIEnv * env, jobject policy, std::string
viatorApi->GetTop5Products(destId, currency, callback);
}
-void Framework::RequestUGC(ugc::Api::UGCCallback const & ugcCallback)
+void Framework::RequestUGC(FeatureID const & fid, ugc::Api::UGCCallback const & ugcCallback)
{
- auto const & info = GetPlacePageInfo();
- if (!info.IsFeature())
- {
- ugcCallback(ugc::UGC{});
- return;
- }
- m_work.GetUGCApi().GetUGC(info.GetID(), ugcCallback);
+ m_work.GetUGCApi().GetUGC(fid, ugcCallback);
}
int Framework::ToDoAfterUpdate() const
diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp
index 51e0cdb641..6e15b8fd9d 100644
--- a/android/jni/com/mapswithme/maps/Framework.hpp
+++ b/android/jni/com/mapswithme/maps/Framework.hpp
@@ -30,6 +30,9 @@
#include <memory>
#include <mutex>
+class Index;
+struct FeatureID;
+
namespace search
{
struct EverywhereSearchParams;
@@ -70,6 +73,7 @@ namespace android
Framework();
storage::Storage & GetStorage();
+ Index const & GetIndex();
void ShowNode(storage::TCountryId const & countryId, bool zoomToDownloadButton);
@@ -196,7 +200,7 @@ namespace android
std::string const & currency,
viator::GetTop5ProductsCallback const & callback);
- void RequestUGC(ugc::Api::UGCCallback const & ugcCallback);
+ void RequestUGC(FeatureID const & fid, ugc::Api::UGCCallback const & ugcCallback);
int ToDoAfterUpdate() const;
diff --git a/android/jni/com/mapswithme/maps/UGC.cpp b/android/jni/com/mapswithme/maps/UGC.cpp
index ead09df286..66b48079d8 100644
--- a/android/jni/com/mapswithme/maps/UGC.cpp
+++ b/android/jni/com/mapswithme/maps/UGC.cpp
@@ -15,7 +15,7 @@ namespace
class FeatureIdBuilder
{
public:
- bool Build(JNIEnv * env, jobject obj, FeatureID & fid)
+ FeatureID Build(JNIEnv * env, jobject obj)
{
Init(env);
@@ -27,8 +27,9 @@ public:
auto const version = static_cast<int64_t>(jversion);
auto const index = static_cast<uint32_t>(jindex);
- // TODO (@y): combine countryName version and index to featureId.
- return false;
+ auto const & ix = g_framework->GetIndex();
+ auto const id = ix.GetMwmIdByCountryFile(platform::CountryFile(countryName));
+ return FeatureID(id, index);
}
private:
@@ -157,10 +158,8 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_mapswithme_maps_ugc_UGC_requestUGC(JNIEnv * env, jclass /* clazz */,
jobject featureId)
{
- FeatureID fid;
- g_builder.Build(env, featureId, fid);
-
- g_framework->RequestUGC([&](ugc::UGC const & ugc) {
+ auto const fid = g_builder.Build(env, featureId);
+ g_framework->RequestUGC(fid, [&](ugc::UGC const & ugc) {
JNIEnv * e = jni::GetEnv();
g_bridge.OnResult(e, ugc);
});
diff --git a/ugc/api.cpp b/ugc/api.cpp
index 543338dd77..550621162b 100644
--- a/ugc/api.cpp
+++ b/ugc/api.cpp
@@ -85,12 +85,14 @@ void Api::GetUGCImpl(FeatureID const & id, UGCCallback callback)
// TODO (@y, @mgsergio): retrieve static UGC
UGC ugc(Rating({}, {}), {}, {});
- auto const r = id.m_index % 3;
-// if (r == 1)
+ if (!id.IsValid())
+ {
+ GetPlatform().RunOnGuiThread([ugc, callback] { callback(ugc); });
+ return;
+ }
+
ugc = MakeTestUGC1();
-// else
-// ugc = MakeTestUGC2();
-
+
GetPlatform().RunOnGuiThread([ugc, callback] { callback(ugc); });
}