Merge pull request #5095 from koying/fixdroidappcrash
[vuplus_xbmc] / xbmc / filesystem / AndroidAppDirectory.cpp
index a7fa9e8..ff7502b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *      Copyright (C) 2012-2013 Team XBMC
- *      http://www.xbmc.org
+ *      http://xbmc.org
  *
  *  This Program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 #include "utils/URIUtils.h"
 #include <vector>
 #include "utils/log.h"
+#include "utils/StringUtils.h"
 #include "URL.h"
 
 using namespace XFILE;
@@ -49,23 +50,21 @@ bool CAndroidAppDirectory::GetDirectory(const CStdString& strPath, CFileItemList
   CLog::Log(LOGDEBUG, "CAndroidAppDirectory::GetDirectory: %s",dirname.c_str()); 
   if (dirname == "apps")
   {
-    vector<androidPackage> applications;
-    CXBMCApp::ListApplications(&applications);
-    if (!applications.size())
+    vector<androidPackage> applications = CXBMCApp::GetApplications();
+    if (applications.empty())
     {
       CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Application lookup listing failed");
       return false;
     }
-    for(unsigned int i = 0; i < applications.size(); i++)
+    for(std::vector<androidPackage>::iterator i = applications.begin(); i != applications.end(); ++i)
     {
-      if (applications[i].packageName == "org.xbmc.xbmc")
+      if ((*i).packageName == "org.xbmc.xbmc")
         continue;
-      CFileItemPtr pItem(new CFileItem(applications[i].packageName));
+      CFileItemPtr pItem(new CFileItem((*i).packageName));
       pItem->m_bIsFolder = false;
-      CStdString path;
-      path.Format("androidapp://%s/%s/%s", url.GetHostName(), dirname,  applications[i].packageName);
+      std::string path = StringUtils::Format("androidapp://%s/%s/%s", url.GetHostName().c_str(), dirname.c_str(), (*i).packageName.c_str());
       pItem->SetPath(path);
-      pItem->SetLabel(applications[i].packageLabel);
+      pItem->SetLabel((*i).packageLabel);
       pItem->SetArt("thumb", path+".png");
       items.Add(pItem);
     }