summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2015-11-16 20:32:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-11-16 20:32:35 +0000
commit1cd7d1209b1e3eec10cb2dd78b172b0d344008df (patch)
tree714e2b846d3533fcedf84ffa614c169809947169
parent1907fd71019ef16d4fc2953d56f1ec0702275aa0 (diff)
parent90004de4330158be2351b9e26ba951f2ccbccfce (diff)
downloaddata-binding-1cd7d1209b1e3eec10cb2dd78b172b0d344008df.tar.gz
Merge "Don't use DynamicUtil now that 1.0-rc5 has been released." into studio-master-dev
-rw-r--r--compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java2
-rw-r--r--compiler/src/main/java/android/databinding/tool/expr/ResourceExpr.java4
-rw-r--r--compiler/src/main/kotlin/android/databinding/tool/writer/DynamicUtilWriter.kt27
3 files changed, 3 insertions, 30 deletions
diff --git a/compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java b/compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java
index 4d1fadb3..5d563b0b 100644
--- a/compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java
+++ b/compiler/src/main/java/android/databinding/annotationprocessor/ProcessDataBinding.java
@@ -103,7 +103,7 @@ public class ProcessDataBinding extends AbstractProcessor {
mLibraryProject = libraryProject;
mMinSdk = minSdk;
considerWritingMapper();
- mChef.writeDynamicUtil();
+ //mChef.writeDynamicUtil();
}
private void considerWritingMapper() {
diff --git a/compiler/src/main/java/android/databinding/tool/expr/ResourceExpr.java b/compiler/src/main/java/android/databinding/tool/expr/ResourceExpr.java
index 8ac352d7..f1cab64c 100644
--- a/compiler/src/main/java/android/databinding/tool/expr/ResourceExpr.java
+++ b/compiler/src/main/java/android/databinding/tool/expr/ResourceExpr.java
@@ -146,11 +146,11 @@ public class ResourceExpr extends Expr {
if ("animator".equals(mResourceType)) return "android.animation.AnimatorInflater.loadAnimator(" + context + ", " + resourceName + ")";
if ("bool".equals(mResourceType)) return resources + ".getBoolean(" + resourceName + ")";
if ("color".equals(mResourceType)) return resources + ".getColor(" + resourceName + ")";
- if ("colorStateList".equals(mResourceType)) return "android.databinding.DynamicUtil.getColorStateListFromResource(getRoot(), " + resourceName + ")";
+ if ("colorStateList".equals(mResourceType)) return "getColorStateListFromResource(" + resourceName + ")";
if ("dimen".equals(mResourceType)) return resources + ".getDimension(" + resourceName + ")";
if ("dimenOffset".equals(mResourceType)) return resources + ".getDimensionPixelOffset(" + resourceName + ")";
if ("dimenSize".equals(mResourceType)) return resources + ".getDimensionPixelSize(" + resourceName + ")";
- if ("drawable".equals(mResourceType)) return "android.databinding.DynamicUtil.getDrawableFromResource(getRoot(), " + resourceName + ")";
+ if ("drawable".equals(mResourceType)) return "getDrawableFromResource(" + resourceName + ")";
if ("fraction".equals(mResourceType)) {
String base = getChildCode(0, "1");
String pbase = getChildCode(1, "1");
diff --git a/compiler/src/main/kotlin/android/databinding/tool/writer/DynamicUtilWriter.kt b/compiler/src/main/kotlin/android/databinding/tool/writer/DynamicUtilWriter.kt
index e180f956..07911e9b 100644
--- a/compiler/src/main/kotlin/android/databinding/tool/writer/DynamicUtilWriter.kt
+++ b/compiler/src/main/kotlin/android/databinding/tool/writer/DynamicUtilWriter.kt
@@ -3,37 +3,10 @@ package android.databinding.tool.writer;
class DynamicUtilWriter() {
public fun write(targetSdk : kotlin.Int) : KCode = kcode("package android.databinding;") {
nl("")
- nl("import android.content.res.ColorStateList;")
- nl("import android.graphics.drawable.Drawable;")
nl("import android.os.Build.VERSION;")
nl("import android.os.Build.VERSION_CODES;")
- nl("import android.view.View;")
nl("")
nl("public class DynamicUtil {")
- tab("@SuppressWarnings(\"deprecation\")") {
- nl("public static ColorStateList getColorStateListFromResource(View root, int resourceId) {")
- if (targetSdk >= 23) {
- tab("if (VERSION.SDK_INT >= VERSION_CODES.M) {") {
- tab("return root.getContext().getColorStateList(resourceId);")
- }
- tab("}")
- }
- tab("return root.getResources().getColorStateList(resourceId);")
- }
- tab("}")
- nl("")
-
- tab("@SuppressWarnings(\"deprecation\")") {
- nl("public static Drawable getDrawableFromResource(View root, int resourceId) {")
- if (targetSdk >= 21) {
- tab("if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {") {
- tab("return root.getContext().getDrawable(resourceId);")
- }
- tab("}")
- }
- tab("return root.getResources().getDrawable(resourceId);")
- }
- tab("}")
nl("}")
}
} \ No newline at end of file