aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
diff options
context:
space:
mode:
authorJosiah Gaskin <josiahgaskin@google.com>2011-08-18 11:39:50 -0700
committerJosiah Gaskin <josiahgaskin@google.com>2011-08-18 14:25:45 -0700
commit882e673462566249a538d72b16917bc6cac8315d (patch)
tree27f9ccafc1515ebd94cc11f61a9b5ddb4b2bc9f6 /ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
parent15e9f6bbf0819aae5248337b313492b5cf6241ae (diff)
downloadsdk-882e673462566249a538d72b16917bc6cac8315d.zip
sdk-882e673462566249a538d72b16917bc6cac8315d.tar.gz
sdk-882e673462566249a538d72b16917bc6cac8315d.tar.bz2
Precompilation only executes AAPT when necessary
This change adds resource tracking to the ResourceManager. Each ResourceRepository now has new methods: void markForIdRefresh() to set the repository as "dirty" boolean needsIdRefresh() to check whether the repository is dirty void setIdsRefreshed() to set the repository as "clean" During the precompilation step, the PreCompiler will query the ResourceManager to see if any of the repositories included in the build are marked as dirty. AAPT will only be run if one or more dirty repositories are found. Repositories are marked as clean when R.java is regenerated and IDs are set in ProjectResources. Change-Id: I575ab819702508eacd247b282c3de8979f2f0ab9
Diffstat (limited to 'ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java')
-rw-r--r--ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java b/ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
index fa8d0e7..6706715 100644
--- a/ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
+++ b/ide_common/src/com/android/ide/common/resources/IdGeneratingResourceFile.java
@@ -31,6 +31,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
@@ -88,8 +89,8 @@ public final class IdGeneratingResourceFile extends ResourceFile
@Override
protected void update() {
- // remove this file from all existing ResourceItem.
- getFolder().getRepository().removeFile(mResourceTypeList, this);
+ // Copy the previous list of ID names
+ Set<String> oldIdNames = mIdResources.keySet();
// reset current content.
mIdResources.clear();
@@ -97,14 +98,21 @@ public final class IdGeneratingResourceFile extends ResourceFile
// need to parse the file and find the IDs.
parseFileForIds();
- // Notify the repository about any changes
- updateResourceItems();
+ // We only need to update the repository if our IDs have changed
+ if (oldIdNames.equals(mIdResources.keySet()) == false) {
+ updateResourceItems();
+ }
}
@Override
protected void dispose() {
+ ResourceRepository repository = getRepository();
+
// Remove declarations from this file from the repository
- getFolder().getRepository().removeFile(mResourceTypeList, this);
+ repository.removeFile(mResourceTypeList, this);
+
+ // Ask for an ID refresh since we'll be taking away ID generating items
+ repository.markForIdRefresh();
}
@Override
@@ -155,6 +163,9 @@ public final class IdGeneratingResourceFile extends ResourceFile
private void updateResourceItems() {
ResourceRepository repository = getRepository();
+ // remove this file from all existing ResourceItem.
+ repository.removeFile(mResourceTypeList, this);
+
// First add this as a layout file
ResourceItem item = repository.getResourceItem(mFileType, mFileName);
item.add(this);
@@ -165,6 +176,9 @@ public final class IdGeneratingResourceFile extends ResourceFile
// add this file to the list of files generating ID resources.
item.add(this);
}
+
+ // Ask the repository for an ID refresh
+ repository.markForIdRefresh();
}
/**