1package android.databinding.tool.writer;
2
3class DynamicUtilWriter() {
4    public fun write(targetSdk : kotlin.Int) : KCode = kcode("package android.databinding;") {
5        nl("")
6        nl("import android.os.Build.VERSION;")
7        nl("import android.os.Build.VERSION_CODES;")
8        nl("")
9        nl("public class DynamicUtil {")
10        tab("@SuppressWarnings(\"deprecation\")")
11        tab("public static int getColorFromResource(final android.view.View root, final int resourceId) {") {
12            if (targetSdk >= 23) {
13                tab("if (VERSION.SDK_INT >= VERSION_CODES.M) {") {
14                    tab("return root.getContext().getColor(resourceId);")
15                }
16                tab("}")
17            }
18            tab("return root.getResources().getColor(resourceId);")
19        }
20        tab("}")
21        nl("}")
22    }
23}