forked from organicmaps/organicmaps
[android] Fixed missing call to Framework::EnterBackground().
This commit is contained in:
parent
ba09aa9c34
commit
f564452ee4
3 changed files with 18 additions and 6 deletions
|
@ -144,6 +144,8 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
|
|||
void Framework::DeleteDrapeEngine()
|
||||
{
|
||||
SaveState();
|
||||
m_work.EnterBackground();
|
||||
|
||||
m_work.DestroyDrapeEngine();
|
||||
}
|
||||
|
||||
|
@ -160,7 +162,7 @@ void Framework::Resize(int w, int h)
|
|||
|
||||
void Framework::DetachSurface()
|
||||
{
|
||||
m_work.EnterBackground();
|
||||
m_work.SetRenderingEnabled(false);
|
||||
|
||||
ASSERT(m_contextFactory != nullptr, ());
|
||||
AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
|
@ -173,7 +175,7 @@ void Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
|||
AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
factory->SetSurface(env, jSurface);
|
||||
|
||||
m_work.EnterForeground();
|
||||
m_work.SetRenderingEnabled(true);
|
||||
}
|
||||
|
||||
void Framework::SetMapStyle(MapStyle mapStyle)
|
||||
|
|
|
@ -1047,8 +1047,7 @@ void Framework::MemoryWarning()
|
|||
|
||||
void Framework::EnterBackground()
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetRenderingEnabled(false);
|
||||
SetRenderingEnabled(false);
|
||||
|
||||
ms::LatLon const ll = MercatorBounds::ToLatLon(GetViewportCenter());
|
||||
alohalytics::Stats::Instance().LogEvent("Framework::EnterBackground", {{"zoom", strings::to_string(GetDrawScale())},
|
||||
|
@ -1068,8 +1067,11 @@ void Framework::EnterForeground()
|
|||
m_startForegroundTime = my::Timer::LocalTime();
|
||||
|
||||
// Drape can be not initialized here in case of the first launch
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetRenderingEnabled(true);
|
||||
// TODO(AlexZ): Why it can't be initialized here? Is it because we call EnterForeground in Android for every
|
||||
// time when activity is created? If yes, then this code should be refactored:
|
||||
// EnterForeground and EnterBackground should be called only when user opens the app and
|
||||
// when user completely leaves the app (and is not just switching between app's activities).
|
||||
SetRenderingEnabled(true);
|
||||
}
|
||||
|
||||
bool Framework::GetCurrentPosition(double & lat, double & lon) const
|
||||
|
@ -1495,6 +1497,12 @@ void Framework::DestroyDrapeEngine()
|
|||
m_drapeEngine.reset();
|
||||
}
|
||||
|
||||
void Framework::SetRenderingEnabled(bool enable)
|
||||
{
|
||||
if (m_drapeEngine)
|
||||
m_drapeEngine->SetRenderingEnabled(enable);
|
||||
}
|
||||
|
||||
void Framework::ConnectToGpsTracker()
|
||||
{
|
||||
m_connectToGpsTrack = true;
|
||||
|
|
|
@ -327,6 +327,8 @@ public:
|
|||
void CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory, DrapeCreationParams && params);
|
||||
ref_ptr<df::DrapeEngine> GetDrapeEngine();
|
||||
void DestroyDrapeEngine();
|
||||
/// Called when graphics engine should be temporarily paused and then resumed.
|
||||
void SetRenderingEnabled(bool enable);
|
||||
|
||||
void ConnectToGpsTracker();
|
||||
void DisconnectFromGpsTracker();
|
||||
|
|
Loading…
Add table
Reference in a new issue