android {
dataBinding {
enabled = true
}
}
public void writeViewBinderInterfaces(boolean isLibrary) {
ensureDataBinder();
mDataBinder.writerBaseClasses(isLibrary);
}
public void writerBaseClasses(boolean isLibrary) {
for (LayoutBinder layoutBinder : mLayoutBinders) {
try {
Scope.enter(layoutBinder);
if (isLibrary || layoutBinder.hasVariations()) {
String className = layoutBinder.getClassName();
String canonicalName = layoutBinder.getPackage() + "." + className;
if (mWrittenClasses.contains(canonicalName)) {
continue;
}
L.d("writing data binder base %s", canonicalName);
mFileWriter.writeToFile(canonicalName,
layoutBinder.writeViewBinderBaseClass(isLibrary));
mWrittenClasses.add(canonicalName);
}
} catch (ScopedException ex){
Scope.defer(ex);
} finally {
Scope.exit();
}
}
}
public String writeViewBinderBaseClass(boolean forLibrary) {
ensureWriter();
return mWriter.writeBaseClass(forLibrary);
}
public fun writeBaseClass(forLibrary : Boolean) : String =
kcode("package ${layoutBinder.`package`};") {
Scope.reset()
nl("import android.databinding.Bindable;")
nl("import android.databinding.DataBindingUtil;")
nl("import android.databinding.ViewDataBinding;")
nl("public abstract class $baseClassName extends ViewDataBinding {")
layoutBinder.sortedTargets.filter{it.id != null}.forEach {
tab("public final ${it.interfaceClass} ${it.fieldName};")
}
nl("")
tab("protected $baseClassName(android.databinding.DataBindingComponent bindingComponent, android.view.View root_, int localFieldCount") {
layoutBinder.sortedTargets.filter{it.id != null}.forEach {
tab(", ${it.interfaceClass} ${it.constructorParamName}")
}
}
tab(") {") {
tab("super(bindingComponent, root_, localFieldCount);")
layoutBinder.sortedTargets.filter{it.id != null}.forEach {
tab("this.${it.fieldName} = ${it.constructorParamName};")
}
}
tab("}")
nl("")
variables.forEach {
if (it.userDefinedType != null) {
val type = ModelAnalyzer.getInstance().applyImports(it.userDefinedType, model.imports)
tab("public abstract void ${it.setterName}($type ${it.readableName});")
}
}
tab("public static $baseClassName inflate(android.view.LayoutInflater inflater, android.view.ViewGroup root, boolean attachToRoot) {") {
tab("return inflate(inflater, root, attachToRoot, android.databinding.DataBindingUtil.getDefaultComponent());")
}
tab("}")
tab("public static $baseClassName inflate(android.view.LayoutInflater inflater) {") {
tab("return inflate(inflater, android.databinding.DataBindingUtil.getDefaultComponent());")
}
tab("}")
tab("public static $baseClassName bind(android.view.View view) {") {
if (forLibrary) {
tab("return null;")
} else {
tab("return bind(view, android.databinding.DataBindingUtil.getDefaultComponent());")
}
}
tab("}")
tab("public static $baseClassName inflate(android.view.LayoutInflater inflater, android.view.ViewGroup root, boolean attachToRoot, android.databinding.DataBindingComponent bindingComponent) {") {
if (forLibrary) {
tab("return null;")
} else {
tab("return DataBindingUtil.<$baseClassName>inflate(inflater, ${layoutBinder.modulePackage}.R.layout.${layoutBinder.layoutname}, root, attachToRoot, bindingComponent);")
}
}
tab("}")
tab("public static $baseClassName inflate(android.view.LayoutInflater inflater, android.databinding.DataBindingComponent bindingComponent) {") {
if (forLibrary) {
tab("return null;")
} else {
tab("return DataBindingUtil.<$baseClassName>inflate(inflater, ${layoutBinder.modulePackage}.R.layout.${layoutBinder.layoutname}, null, false, bindingComponent);")
}
}
tab("}")
tab("public static $baseClassName bind(android.view.View view, android.databinding.DataBindingComponent bindingComponent) {") {
if (forLibrary) {
tab("return null;")
} else {
tab("return ($baseClassName)bind(bindingComponent, view, ${layoutBinder.modulePackage}.R.layout.${layoutBinder.layoutname});")
}
}
tab("}")
nl("}")
}.generate()
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有