Save addons xml when going into background for mobile stk
So the icons don't need to be redownloaded again after it's killed by OS in the background
This commit is contained in:
parent
93e95a0c39
commit
dce9bf1e63
@ -59,6 +59,7 @@ AddonsManager* addons_manager = 0;
|
||||
AddonsManager::AddonsManager() : m_addons_list(std::vector<Addon>() ),
|
||||
m_state(STATE_INIT)
|
||||
{
|
||||
m_downloaded_icons = false;
|
||||
// Clean .part file which may be left behind
|
||||
std::string addons_part = file_manager->getAddonsFile("addons.xml.part");
|
||||
if (file_manager->fileExists(addons_part))
|
||||
@ -393,6 +394,11 @@ void AddonsManager::downloadIcons()
|
||||
void afterOperation()
|
||||
{
|
||||
m_addon->setIconReady();
|
||||
} // afterOperation
|
||||
void callback()
|
||||
{
|
||||
if (!hadDownloadError())
|
||||
addons_manager->m_downloaded_icons = true;
|
||||
} // callback
|
||||
public:
|
||||
IconRequest(const std::string &filename,
|
||||
@ -632,6 +638,7 @@ void AddonsManager::saveInstalled()
|
||||
}
|
||||
xml_installed << "</addons>" << std::endl;
|
||||
xml_installed.close();
|
||||
m_downloaded_icons = false;
|
||||
} // saveInstalled
|
||||
|
||||
#endif
|
||||
|
@ -53,6 +53,12 @@ private:
|
||||
// Synchronise the state between threads (e.g. GUI and update thread)
|
||||
Synchronised<STATE_TYPE> m_state;
|
||||
|
||||
/* Return true if any icons have been downloaded, so we need to call
|
||||
* saveInstalled in mobile stk when pressing home button, so the icons
|
||||
* won't need to be redownload when stk is killed by OS in the
|
||||
* background. */
|
||||
bool m_downloaded_icons;
|
||||
|
||||
void loadInstalledAddons();
|
||||
void downloadIcons();
|
||||
|
||||
@ -88,7 +94,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the i-th addons. */
|
||||
const Addon& getAddon(unsigned int i) { return m_addons_list.getData()[i];}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
bool hasDownloadedIcons() const { return m_downloaded_icons; }
|
||||
}; // class AddonsManager
|
||||
|
||||
extern AddonsManager *addons_manager;
|
||||
|
@ -17,6 +17,9 @@
|
||||
|
||||
#include "guiengine/event_handler.hpp"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "addons/addons_manager.hpp"
|
||||
#endif
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -182,6 +185,8 @@ bool EventHandler::OnEvent (const SEvent &event)
|
||||
music_manager->pauseMusic();
|
||||
SFXManager::get()->pauseAll();
|
||||
}
|
||||
if (addons_manager->hasDownloadedIcons())
|
||||
addons_manager->saveInstalled();
|
||||
}
|
||||
else if (cmd == APP_CMD_RESUME || cmd == APP_CMD_GAINED_FOCUS)
|
||||
{
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
#include "main_loop.hpp"
|
||||
|
||||
#ifdef IOS_STK
|
||||
#include "addons/addons_manager.hpp"
|
||||
#endif
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -128,6 +131,8 @@ float MainLoop::getLimitedDt()
|
||||
first_out_focus = false;
|
||||
music_manager->pauseMusic();
|
||||
SFXManager::get()->pauseAll();
|
||||
if (addons_manager->hasDownloadedIcons())
|
||||
addons_manager->saveInstalled();
|
||||
}
|
||||
dev->run();
|
||||
win_active = dev->isWindowActive();
|
||||
|
Loading…
Reference in New Issue
Block a user