Fixed pending position running on app start

This commit is contained in:
r.kuznetsov 2016-04-29 16:38:35 +03:00 committed by Alex Zolotarev
parent f5b9cf9062
commit 81e981a15b
2 changed files with 20 additions and 0 deletions

View file

@ -26,6 +26,7 @@ double const kMaxPendingLocationTimeSec = 60.0;
double const kMaxTimeInBackgroundSec = 60.0 * 60;
double const kMaxNotFollowRoutingTimeSec = 10.0;
double const kMaxUpdateLocationInvervalSec = 30.0;
double const kMaxWaitStartLocationSec = 5.0;
int const kDoNotChangeZoom = -1;
@ -113,6 +114,8 @@ MyPositionController::MyPositionController(location::EMyPositionMode initMode,
m_mode = location::NotFollowNoPosition;
else if (timeInBackground >= kMaxTimeInBackgroundSec)
m_mode = location::Follow;
m_startLocationTimer.Reset();
}
MyPositionController::~MyPositionController()
@ -379,6 +382,12 @@ void MyPositionController::SetModeListener(location::TMyPositionModeChanged cons
m_modeChangeCallback(mode, m_isInRouting);
}
bool MyPositionController::IsInStateWithPosition() const
{
return m_mode == location::NotFollow || m_mode == location::Follow ||
m_mode == location::FollowAndRotate;
}
void MyPositionController::Render(uint32_t renderMode, ScreenBase const & screen,
ref_ptr<dp::GpuProgramManager> mng,
dp::UniformValuesStorage const & commonUniforms)
@ -389,6 +398,15 @@ void MyPositionController::Render(uint32_t renderMode, ScreenBase const & screen
ChangeMode(location::NotFollowNoPosition);
}
// We do not have assigned position but mode requires location.
// Go to Pending state if the time is up.
if (!m_isPositionAssigned && IsInStateWithPosition() &&
m_startLocationTimer.ElapsedSeconds() >= kMaxWaitStartLocationSec)
{
m_pendingTimer.Reset();
ChangeMode(location::PendingPosition);
}
if (IsInRouting() && m_mode == location::NotFollow &&
m_routingNotFollowTimer.ElapsedSeconds() >= kMaxNotFollowRoutingTimeSec)
{

View file

@ -103,6 +103,7 @@ private:
void ChangeMode(location::EMyPositionMode newMode);
void SetDirection(double bearing);
bool IsInStateWithPosition() const;
bool IsVisible() const { return m_isVisible; }
void SetIsVisible(bool isVisible) { m_isVisible = isVisible; }
@ -146,6 +147,7 @@ private:
my::Timer m_pendingTimer;
my::Timer m_routingNotFollowTimer;
my::Timer m_updateLocationTimer;
my::Timer m_startLocationTimer;
double m_lastLocationTimestamp;
m2::RectD m_pixelRect;