aboutsummaryrefslogtreecommitdiffstats
path: root/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-03-29 11:01:49 -0700
committerXavier Ducrohet <xav@android.com>2011-03-29 11:26:15 -0700
commit6f3c6c2c0a88b035ad4b2075e030ce69372fa509 (patch)
tree2df95a26bf4f7d6ba56f8e95239aae1496091e88 /layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
parent109612be76acf29786c0dc3c99a36f5661af3c5a (diff)
downloadsdk-6f3c6c2c0a88b035ad4b2075e030ce69372fa509.zip
sdk-6f3c6c2c0a88b035ad4b2075e030ce69372fa509.tar.gz
sdk-6f3c6c2c0a88b035ad4b2075e030ce69372fa509.tar.bz2
Add support for data binding in the layout editor.
The Layoutlib_api is changed to allow passing information regarding adapter content, and querying eclipse to fill the items. Change-Id: Ie5a047ab9cd0ed7677c13309d95663eae462c3e7
Diffstat (limited to 'layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java')
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
new file mode 100644
index 0000000..71839e1
--- /dev/null
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.common.rendering.api;
+
+/**
+ * A resource reference. This contains the String ID of the resource and whether this is a framework
+ * reference.
+ *
+ */
+public class ResourceReference {
+ private final String mName;
+ private final boolean mIsFramework;
+
+ /**
+ * Builds a resource reference.
+ * @param name the name of the resource
+ * @param isFramework whether the reference is to a framework resource.
+ */
+ public ResourceReference(String name, boolean isFramework) {
+ mName = name;
+ mIsFramework = isFramework;
+ }
+
+ /**
+ * Builds a non-framework resource reference.
+ * @param name the name of the resource
+ */
+ public ResourceReference(String name) {
+ this(name, false /*platformLayout*/);
+ }
+
+ /**
+ * Returns the name of the resource, as defined in the XML.
+ */
+ public final String getName() {
+ return mName;
+ }
+
+ /**
+ * Returns whether the resource is a framework resource (<code>true</code>) or a project
+ * resource (<code>false</false>).
+ */
+ public final boolean isFramework() {
+ return mIsFramework;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (mIsFramework ? 1231 : 1237);
+ result = prime * result + ((mName == null) ? 0 : mName.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResourceReference other = (ResourceReference) obj;
+ if (mIsFramework != other.mIsFramework)
+ return false;
+ if (mName == null) {
+ if (other.mName != null)
+ return false;
+ } else if (!mName.equals(other.mName))
+ return false;
+ return true;
+ }
+}