From 2921f35fcf579294b1926e6fdf1d6ef905ecb561 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 18 Feb 2011 16:29:26 -0800 Subject: [PATCH] Properly parse mipmap names. The extension was not removed making the references not found. Change-Id: Ie420ea26df5bb87b86bd5b156597962b8c49252f --- .../resources/manager/SingleResourceFile.java | 40 +++------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java index 953e57ae1..22bdc249c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java @@ -24,8 +24,6 @@ import com.android.sdklib.io.IAbstractFile; import java.util.ArrayList; import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.xml.parsers.SAXParserFactory; @@ -42,16 +40,6 @@ public class SingleResourceFile extends ResourceFile { sParserFactory.setNamespaceAware(true); } - private final static Pattern sXmlPattern = Pattern.compile("^(.+)\\.xml", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE); - - private final static Pattern[] sDrawablePattern = new Pattern[] { - Pattern.compile("^(.+)\\.9\\.png", Pattern.CASE_INSENSITIVE), //$NON-NLS-1$ - Pattern.compile("^(.+)\\.png", Pattern.CASE_INSENSITIVE), //$NON-NLS-1$ - Pattern.compile("^(.+)\\.jpg", Pattern.CASE_INSENSITIVE), //$NON-NLS-1$ - Pattern.compile("^(.+)\\.gif", Pattern.CASE_INSENSITIVE), //$NON-NLS-1$ - }; - private String mResourceName; private ResourceType mType; private ResourceValue mValue; @@ -133,31 +121,11 @@ public class SingleResourceFile extends ResourceFile { // get the name from the filename. String name = getFile().getName(); - if (type == ResourceType.ANIM || - type == ResourceType.ANIMATOR || - type == ResourceType.COLOR || - type == ResourceType.INTERPOLATOR || - type == ResourceType.LAYOUT || - type == ResourceType.MENU || - type == ResourceType.XML) { - Matcher m = sXmlPattern.matcher(name); - if (m.matches()) { - return m.group(1); - } - } else if (type == ResourceType.DRAWABLE) { - for (Pattern p : sDrawablePattern) { - Matcher m = p.matcher(name); - if (m.matches()) { - return m.group(1); - } - } - - // also try the Xml pattern for selector/shape based drawable. - Matcher m = sXmlPattern.matcher(name); - if (m.matches()) { - return m.group(1); - } + int pos = name.indexOf('.'); + if (pos != -1) { + name = name.substring(0, pos); } + return name; } } -- 2.11.0