Esempio n. 1
0
 private void updateProjectCache() {
   // Ensure we have a cache at all:
   initProjectCache();
   // Loop through project path preference keys:
   for (Map.Entry<String, ?> entry : preferences.getAll().entrySet())
     if (entry.getKey().startsWith(PREF_PROJECT_PATH_PREFIX)
         && entry.getKey().endsWith(PREF_PROJECT_PATH_POSTFIX)) {
       int projectID = getProjectID(entry.getKey());
       int projectFingerPrint = getProjectFingerPrint(entry.getKey());
       if (getCachedProject(projectID, projectFingerPrint)
           == null) { // Parse the project if it is not already in the cache:
         Project p = ProjectLoader.ParseProject(entry.getValue().toString());
         if (p != null) {
           if (p.getFingerPrint() != projectFingerPrint) {
             Log.w(
                 TAG,
                 "XML finger print of project "
                     + p.toString()
                     + " has changed, possibly the "
                     + ProjectLoader.PROJECT_FILE
                     + " file (located in "
                     + entry.getValue().toString()
                     + ") was manually edited!");
             // Remove old pref key:
             removeProjectPathPrefKey(projectID, projectFingerPrint);
             // Add new pref key:
             storeProjectPathPrefKey(p);
           }
           // Cache the project object:
           cacheProject(p);
         }
       }
     }
 }
Esempio n. 2
0
 /**
  * Gets project from cache if it is there, returns null otherwise
  *
  * @param projectID
  * @param projectFingerPrint
  * @return
  */
 private Project getCachedProject(int projectID, int projectFingerPrint) {
   if (projectCache != null)
     for (Project cachedProj : projectCache)
       if (cachedProj.getID() == projectID && cachedProj.getFingerPrint() == projectFingerPrint)
         return cachedProj;
   return null;
 }
Esempio n. 3
0
 private Record getProjectRecord(Project project) {
   Record projRec = PROJECT_SCHEMA.createRecord();
   PROJECT_ID_COLUMN.storeValue(projRec, project.getID());
   PROJECT_FINGERPRINT_COLUMN.storeValue(projRec, project.getFingerPrint());
   PROJECT_NAME_COLUMN.storeValue(projRec, project.getName());
   String projVariant = project.getVariant();
   PROJECT_VARIANT_COLUMN.storeValue(
       projRec, projVariant != null ? projVariant : ""); // replace null by empty string!
   PROJECT_VERSION_COLUMN.storeValue(projRec, project.getVersion());
   PROJECT_V1X_SCHEMA_VERSION_COLUMN.storeValue(projRec, project.getV1XSchemaVersion());
   return projRec;
 }
Esempio n. 4
0
 private String getProjectPathPrefKey(Project project) {
   return getProjectPathPrefKey(project.getID(), project.getFingerPrint());
 }