我在使用源集时遇到了一些问题,我有一个包含大部分通用代码的主源集,但是之前的开发人员包含了一个构建风格开关,例如:
if (Application.inKiosk) {
navigation.visibility = View.INVISIBLE
val employeeSelectionFragment = EmployeeSelectionFragment()
employeeSelectionFragment.setAllList(employees)
employeeSelectionFragment.setCallback(employeeSelected)
supportFragmentManager.beginTransaction().add(R.id.small_container, employeeSelectionFragment, "EmployeeSelectionFragment").commitNow()
currentTimeRecord = TimeRecord()
} else {
setupTimeRecords(employees!!.first()!!.id, savedInstanceState == null)
}
我想提取这个风味特定的块并将其包含在它自己的源集文件夹中。我无法访问通用成员,例如导航。我将如何提取此部分?
navigation.visibility = View.INVISIBLE
val employeeSelectionFragment = EmployeeSelectionFragment()
employeeSelectionFragment.setAllList(employees)
employeeSelectionFragment.setCallback(employeeSelected)
supportFragmentManager.beginTransaction().add(R.id.small_container, employeeSelectionFragment, "EmployeeSelectionFragment").commitNow()
currentTimeRecord = TimeRecord()