[IPHONE] Memory Warning Message.

This commit is contained in:
rachytski 2011-01-26 02:12:29 +02:00 committed by Alex Zolotarev
parent db268385ee
commit 36b7db76d4
4 changed files with 52 additions and 0 deletions

View file

@ -255,6 +255,9 @@ typedef FrameWork<model::FeaturesFetcher, Navigator, iphone::WindowHandle> frame
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
m_framework->MemoryWarning();
m_framework->Repaint();
// Release any cached data, images, etc that aren't in use.
}

View file

@ -370,6 +370,11 @@ public:
UpdateNow();
}
void MemoryWarning()
{
m_informationDisplay.memoryWarning();
}
void CenterViewport()
{
m_navigator.CenterViewport(m_informationDisplay.position());

View file

@ -19,6 +19,7 @@ InformationDisplay::InformationDisplay()
enableRuler(false);
enableCenter(false);
enableDebugInfo(false);
enableMemoryWarning(false);
for (int i = 0; i < sizeof(m_DebugPts) / sizeof(m2::PointD); ++i)
m_DebugPts[i] = m2::PointD(0, 0);
@ -322,6 +323,39 @@ void InformationDisplay::drawDebugInfo(DrawerYG * drawer)
false);
}
void InformationDisplay::enableMemoryWarning(bool flag)
{
m_isMemoryWarningEnabled = flag;
}
void InformationDisplay::memoryWarning()
{
enableMemoryWarning(true);
m_lastMemoryWarning = my::Timer();
}
void InformationDisplay::drawMemoryWarning(DrawerYG * drawer)
{
m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + 20);
if (m_isDebugInfoEnabled)
pos += m2::PointD(0, 30);
if (m_isCenterEnabled)
pos += m2::PointD(0, 30);
ostringstream out;
out << "MemoryWarning : " << m_lastMemoryWarning.ElapsedSeconds() << " sec. ago.";
drawer->screen()->drawText(pos,
0, 10,
out.str().c_str(),
yg::maxDepth,
true,
false);
if (m_lastMemoryWarning.ElapsedSeconds() > 5)
enableMemoryWarning(false);
}
void InformationDisplay::doDraw(DrawerYG *drawer)
{
if (m_isHeadingEnabled)
@ -336,4 +370,6 @@ void InformationDisplay::doDraw(DrawerYG *drawer)
drawCenter(drawer);
if (m_isDebugInfoEnabled)
drawDebugInfo(drawer);
if (m_isMemoryWarningEnabled)
drawMemoryWarning(drawer);
}

View file

@ -3,6 +3,7 @@
#include "../geometry/point2d.hpp"
#include "../geometry/rect2d.hpp"
#include "../geometry/screenbase.hpp"
#include "../base/timer.hpp"
class DrawerYG;
@ -43,6 +44,9 @@ private:
double m_bottomShift;
double m_visualScale;
my::Timer m_lastMemoryWarning;
bool m_isMemoryWarningEnabled;
public:
InformationDisplay();
@ -77,5 +81,9 @@ public:
void setDebugInfo(double frameDuration, int currentScale);
void drawDebugInfo(DrawerYG * pDrawer);
void enableMemoryWarning(bool doEnable);
void memoryWarning();
void drawMemoryWarning(DrawerYG * pDrawer);
void doDraw(DrawerYG * drawer);
};