[tips] review fixes

This commit is contained in:
Arsentiy Milchakov 2020-01-23 20:35:18 +03:00 committed by Daria Volvenkova
parent 453ad5463c
commit ee77f38ccd
4 changed files with 24 additions and 32 deletions

View file

@ -2,6 +2,7 @@ package com.mapswithme.maps.maplayer;
import android.app.Activity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
@ -56,7 +57,7 @@ public class MapLayerCompositeController implements MapLayerController
isoLinesView.setOnClickListener(dialogClickListener);
ControllerAndMode subwayEntry = new ControllerAndMode(Mode.SUBWAY, Tutorial.SUBWAY,
subwayMapLayerController);
ControllerAndMode trafficEntry = new ControllerAndMode(Mode.TRAFFIC, Tutorial.STUB,
ControllerAndMode trafficEntry = new ControllerAndMode(Mode.TRAFFIC, null,
trafficButtonController);
ControllerAndMode isoLineEntry = new ControllerAndMode(Mode.ISOLINES, Tutorial.ISOLINES,
isoLinesController);
@ -66,17 +67,14 @@ public class MapLayerCompositeController implements MapLayerController
// entries.add(isoLineEntry);
entries.add(trafficEntry);
if (tutorial != Tutorial.STUB)
Collections.sort(entries, (lhs, rhs) ->
{
Collections.sort(entries, (lhs, rhs) ->
{
if (lhs.getTutorial().equals(tutorial))
return 1;
if (rhs.getTutorial().equals(tutorial))
return -1;
return 0;
});
}
if (lhs.getTutorial() == tutorial)
return -1;
if (rhs.getTutorial() == tutorial)
return 1;
return 0;
});
return Collections.unmodifiableList(entries);
}
@ -252,12 +250,12 @@ public class MapLayerCompositeController implements MapLayerController
{
@NonNull
private final Mode mMode;
@NonNull
@Nullable
private final Tutorial mTutorial;
@NonNull
private final MapLayerController mController;
ControllerAndMode(@NonNull Mode mode, @NonNull Tutorial tutorial,
ControllerAndMode(@NonNull Mode mode, @Nullable Tutorial tutorial,
@NonNull MapLayerController controller)
{
mMode = mode;
@ -292,7 +290,7 @@ public class MapLayerCompositeController implements MapLayerController
return mMode;
}
@NonNull
@Nullable
Tutorial getTutorial()
{
return mTutorial;

View file

@ -8,6 +8,7 @@
#include "base/timer.hpp"
#include <type_traits>
#include <unordered_set>
#include <utility>
using namespace eye;
@ -27,7 +28,7 @@ size_t constexpr kActionClicksCountToDisable = 1;
// If a user clicks 3 times on the button GOT IT the appropriate screen will never be shown again.
size_t constexpr kGotitClicksCountToDisable = 3;
auto constexpr kIsolinesExceptedMwms =
std::unordered_set<std::string> const kIsolinesExceptedMwms =
{
"Argentina_Buenos Aires_Buenos Aires",
"Australia_Melbourne",
@ -110,7 +111,7 @@ std::optional<eye::Tip::Type> GetTipImpl(TipsApi::Duration showAnyTipPeriod,
}
// Iterates reversed because we need to show newest tip first.
for (auto c = candidates.crbegin(); c != candidates.rend(); ++c)
for (auto c = candidates.crbegin(); c != candidates.crend(); ++c)
{
if (c->second && conditions[ToIndex(c->first)](*info))
return c->first;
@ -199,12 +200,10 @@ TipsApi::TipsApi(std::unique_ptr<Delegate> delegate)
{
for (auto const & layer : info.m_layers)
{
if (layer.m_type == Layer::Type::PublicTransport)
if (layer.m_type == Layer::Type::PublicTransport &&
layer.m_lastTimeUsed.time_since_epoch().count() != 0)
{
if (layer.m_lastTimeUsed.time_since_epoch().count() != 0)
{
return false;
}
return false;
}
}
@ -219,23 +218,18 @@ TipsApi::TipsApi(std::unique_ptr<Delegate> delegate)
{
for (auto const & layer : info.m_layers)
{
if (layer.m_type == Layer::Type::Isolines)
if (layer.m_type == Layer::Type::Isolines &&
layer.m_lastTimeUsed.time_since_epoch().count() != 0)
{
if (layer.m_lastTimeUsed.time_since_epoch().count() != 0)
{
return false;
}
return false;
}
}
auto const pos = m_delegate->GetViewportCenter();
auto const countryId = m_delegate->GetCountryId(pos);
for (auto const & exceptedMwmId : kIsolinesExceptedMwms)
{
if (exceptedMwmId == countryId)
if (kIsolinesExceptedMwms.find(countryId) != kIsolinesExceptedMwms.end())
return false;
}
return m_delegate->GetCountryVersion(countryId) > 191124;
},

View file

@ -1,6 +1,6 @@
#include "map/tips_api_delegate.hpp"
TipsApiDelegate::TipsApiDelegate(Framework & framework)
TipsApiDelegate::TipsApiDelegate(Framework const & framework)
: m_framework(framework)
{
}

View file

@ -7,7 +7,7 @@
class TipsApiDelegate : public TipsApi::Delegate
{
public:
TipsApiDelegate(Framework & framework);
explicit TipsApiDelegate(Framework const & framework);
boost::optional<m2::PointD> GetCurrentPosition() const override;
bool IsCountryLoaded(m2::PointD const & pt) const override;