[ugc][android] FeatureID is fully exposed to UGC Api.

This commit is contained in:
Yuri Gorshenin 2017-06-21 16:44:36 +03:00 committed by Yuri Gorshenin
parent b095454bb4
commit 00d2363b63
4 changed files with 22 additions and 21 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);
});

View file

@ -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); });
}