forked from organicmaps/organicmaps
[android] Fix to previous commit - added GetFilesInDir support
This commit is contained in:
parent
3c62937413
commit
e5f6e76b37
3 changed files with 29 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "framework.h"
|
||||
#include "android_framework.hpp"
|
||||
#include "jni_helper.h"
|
||||
#include "rendering.h"
|
||||
#include "../../std/shared_ptr.hpp"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "platform.h"
|
||||
#include "android_platform.hpp"
|
||||
#include "jni_string.h"
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
|
@ -19,19 +19,34 @@ ModelReader * AndroidPlatform::GetReader(string const & file) const
|
|||
if (IsFileExists(m_writableDir + file))
|
||||
return BasePlatformImpl::GetReader(file);
|
||||
else
|
||||
return new ZipFileReader(m_resourcesDir, "assets/" + file);
|
||||
{ // paths from GetFilesInDir will already contain "assets/"
|
||||
if (file.find("assets/") != string::npos)
|
||||
return new ZipFileReader(m_resourcesDir, file);
|
||||
else
|
||||
return new ZipFileReader(m_resourcesDir, "assets/" + file);
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidPlatform::GetFontNames(FilesList & res) const
|
||||
void AndroidPlatform::GetFilesInDir(string const & directory, string const & mask, FilesList & res) const
|
||||
{
|
||||
res.push_back("01_dejavusans.ttf");
|
||||
res.push_back("02_wqy-microhei.ttf");
|
||||
res.push_back("03_jomolhari-id-a3d.ttf");
|
||||
res.push_back("04_padauk.ttf");
|
||||
res.push_back("05_khmeros.ttf");
|
||||
res.push_back("06_code2000.ttf");
|
||||
|
||||
/// @todo Need to make refactoring of yg fonts
|
||||
if (ZipFileReader::IsZip(directory))
|
||||
{ // Get files list inside zip file
|
||||
res = ZipFileReader::FilesList(directory);
|
||||
// filter out according to the mask
|
||||
// @TODO we don't support wildcards at the moment
|
||||
string fixedMask = mask;
|
||||
if (fixedMask.size() && fixedMask[0] == '*')
|
||||
fixedMask.erase(0, 1);
|
||||
for (FilesList::iterator it = res.begin(); it != res.end();)
|
||||
{
|
||||
if (it->find(fixedMask) == string::npos)
|
||||
it = res.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
else
|
||||
BasePlatformImpl::GetFilesInDir(directory, mask, res);
|
||||
}
|
||||
|
||||
int AndroidPlatform::CpuCores() const
|
||||
|
|
|
@ -10,8 +10,9 @@ public:
|
|||
void Initialize(JNIEnv * env, jobject activity, jstring apkPath, jstring storagePath);
|
||||
|
||||
virtual ModelReader * GetReader(string const & file) const;
|
||||
/// Overrided to support zip file listing
|
||||
virtual void GetFilesInDir(string const & directory, string const & mask, FilesList & res) const;
|
||||
|
||||
virtual void GetFontNames(FilesList & res) const;
|
||||
virtual int CpuCores() const;
|
||||
virtual string DeviceID() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue