[ios][android][ugc] review fixes.

This commit is contained in:
Arsentiy Milchakov 2019-02-21 13:26:43 +03:00 committed by Aleksey Belousov
parent 0e0cab56c7
commit da5c046bea
8 changed files with 42 additions and 46 deletions

View file

@ -14,14 +14,9 @@ namespace
void RegisterEventIfPossible(eye::MapObject::Event::Type const type)
{
auto & info = g_framework->GetPlacePageInfo();
auto const userPos = g_framework->NativeFramework()->GetCurrentPosition();
if (userPos)
{
auto const mapObject = utils::MakeEyeMapObject(info);
if (!mapObject.IsEmpty())
eye::Eye::Event::MapObjectEvent(mapObject, type, userPos.get());
}
utils::RegisterEyeEventIfPossible(type, userPos, info);
}
} // namespace

View file

@ -119,13 +119,10 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
if (!ConnectionState.isConnected())
{
if (isAuthorized())
{
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_auth);
}
else
{
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_not_auth);
}
finishActivity();
return;
}

View file

@ -12,6 +12,7 @@
#include "local_ads/event.hpp"
#include "map/bookmark_helpers.hpp"
#include "map/utils.hpp"
#include "platform/preferred_languages.hpp"
@ -660,13 +661,19 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
UGCUpdate update{r, t, std::chrono::system_clock::now()};
GetFramework().GetUGCApi()->SetUGCUpdate(m_info.GetID(), update,
[resultHandler](Storage::SettingResult const result)
[resultHandler, info = m_info](Storage::SettingResult const result)
{
if (result != Storage::SettingResult::Success)
return resultHandler(NO);
{
resultHandler(NO);
return;
}
resultHandler(YES);
GetFramework().UpdatePlacePageInfoForCurrentSelection();
utils::RegisterEyeEventIfPossible(eye::MapObject::Event::Type::UgcSaved,
GetFramework().GetCurrentPosition(), info);
});
}

View file

@ -70,12 +70,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName)
void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page::Info const & info)
{
auto const userPos = GetFramework().GetCurrentPosition();
if (userPos)
{
auto const mapObject = utils::MakeEyeMapObject(info);
if (!mapObject.IsEmpty())
eye::Eye::Event::MapObjectEvent(mapObject, type, userPos.get());
}
utils::RegisterEyeEventIfPossible(type, userPos, info);
}
} // namespace
@ -691,22 +686,12 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page:
auto data = self.data;
if (!data)
{
NSAssert(false, @"");
resultHandler(NO);
return;
NSAssert(false, @"");
resultHandler(NO);
return;
}
__weak auto weakData = data;
[data setUGCUpdateFrom:model resultHandler:^(BOOL result)
{
if (result)
{
auto data = weakData;
if (data)
RegisterEventIfPossible(eye::MapObject::Event::Type::UgcSaved, data.getRawData);
}
resultHandler(result);
}];
[data setUGCUpdateFrom:model resultHandler:resultHandler];
}
@end

View file

@ -33,7 +33,7 @@ final class UGCAddReviewController: MWMTableViewController {
}
private var sections: [Sections] = []
private var delegate: UGCAddReviewControllerDelegate?
private var delegate: UGCAddReviewControllerDelegate!
override func viewDidLoad() {
super.viewDidLoad()
@ -70,7 +70,7 @@ final class UGCAddReviewController: MWMTableViewController {
reviewPosted = true
model.text = text
delegate!.saveUgc(model: model, resultHandler: { (saveResult) in
delegate.saveUgc(model: model, resultHandler: { (saveResult) in
guard let nc = self.navigationController else { return }
if !saveResult {

View file

@ -2456,16 +2456,8 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t
{
GetBookmarkManager().SelectionMark().SetPtOrg(outInfo.GetMercator());
auto const userPos = GetCurrentPosition();
if (userPos)
{
auto const mapObject = utils::MakeEyeMapObject(outInfo);
if (!mapObject.IsEmpty())
{
eye::Eye::Event::MapObjectEvent(mapObject, eye::MapObject::Event::Type::Open,
userPos.get());
}
}
utils::RegisterEyeEventIfPossible(eye::MapObject::Event::Type::Open, GetCurrentPosition(),
outInfo);
return df::SelectionShape::OBJECT_POI;
}

View file

@ -6,6 +6,8 @@
#include "indexer/feature_algo.hpp"
#include "indexer/feature_decl.hpp"
#include "metrics/eye.hpp"
namespace utils
{
eye::MapObject MakeEyeMapObject(place_page::Info const & info)
@ -50,4 +52,16 @@ eye::MapObject MakeEyeMapObject(FeatureType & ft)
return mapObject;
}
void RegisterEyeEventIfPossible(eye::MapObject::Event::Type const type,
boost::optional<m2::PointD> const & userPos,
place_page::Info const & info)
{
if (!userPos)
return;
auto const mapObject = utils::MakeEyeMapObject(info);
if (!mapObject.IsEmpty())
eye::Eye::Event::MapObjectEvent(mapObject, type, *userPos);
}
} // namespace utils

View file

@ -2,6 +2,8 @@
#include "metrics/eye_info.hpp"
#include <boost/optional.hpp>
namespace place_page
{
class Info;
@ -13,4 +15,8 @@ namespace utils
{
eye::MapObject MakeEyeMapObject(place_page::Info const & info);
eye::MapObject MakeEyeMapObject(FeatureType & ft);
void RegisterEyeEventIfPossible(eye::MapObject::Event::Type const type,
boost::optional<m2::PointD> const & userPos,
place_page::Info const & info);
} // namespace utils