Я разрабатываю приложение для Android с использованием Kotlin, но у меня появляются следующие ошибки
C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (118, 9): Function invocation 'levelUp(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (118, 9): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (118, 17): Unresolved reference: setOnClickListener
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (123, 9): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (123, 9): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (123, 19): Unresolved reference: setOnClickListener
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (146, 17): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (146, 17): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (146, 27): Unresolved reference: isEnabled
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (147, 17): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (147, 17): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (147, 27): Unresolved reference: alpha
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (149, 17): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (149, 17): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (149, 27): Unresolved reference: isEnabled
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (150, 17): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (150, 17): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (150, 27): Unresolved reference: alpha
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (153, 13): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (153, 13): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (153, 23): Unresolved reference: isEnabled
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (154, 13): Function invocation 'levelDown(...)' expected
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (154, 13): No value passed for parameter 'therapyPackage'
e: C:\Users\admin\Desktop\masters\app\src\main\java\com\empowered\healo\ui\screens\therapy\TherapySettingsFragment.kt: (154, 23): Unresolved reference: alpha
ниже моего файла TherapySettingsFragment.kt
class TherapySettingsFragment : BaseMvpFragment(), TherapySettingView {
private var data = emptyList<TherapyPackage>()
private var presenter = TherapySettingsPresenter(this)
private var time = 0
private var currentItem: TherapyPackage? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
rootView = inflater.inflate(R.layout.fragment_therapy_settings, container, false)
return rootView
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
toolbar.setOnNavigateIconClickListener { router.exit() }
toolbar.setOnToolIconClickListener { openNavDrawer() }
viewPager.adapter = object : PagerAdapter() {
override fun isViewFromObject(view: View, `object`: Any): Boolean {
return view == `object`
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
container.removeView(`object` as RelativeLayout?)
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val contentView = RelativeLayout(container.context)
contentView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
val text = TextView(container.context)
val item = data[position]
text.text = getString(R.string.level_title, item.title?.getText, item.activeTherapyPackageLevel?.levelName?.getText)
text.typeface = context?.let { ResourcesCompat.getFont(it, R.font.grotesk_light) }
text.textSize = 26f
text.letterSpacing = 0.06f
text.setLineSpacing(1.2f, 1.15f)
text.gravity = Gravity.CENTER
text.setTextColor(Color.WHITE)
val params = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE)
contentView.addView(text, params)
container.addView(contentView)
return contentView
}
override fun getItemPosition(`object`: Any): Int {
return POSITION_NONE
}
override fun getCount(): Int =
data.count()
}
presenter.getPackages()
presenter.getDuration()
timer.text = time.toString()
decTime.setOnClickListener {
if (time > 0) {
time--
timer.text = time.toString()
}
}
incTime.setOnClickListener {
if (time < 60) {
time++
timer.text = time.toString()
}
}
viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
currentItem = data[position]
checkArrowState(position)
}
})
levelUp().setOnClickListener {
if (currentItem != null)
presenter.checkLevelUp(currentItem!!)
}
levelDown.setOnClickListener {
if (currentItem != null)
presenter.packageLevelDown(currentItem!!)
}
checkArrowState(0)
rightBtn.setOnClickListener { viewPager.currentItem = viewPager.currentItem + 1 }
leftBtn.setOnClickListener { viewPager.currentItem = viewPager.currentItem - 1 }
}
private fun checkArrowState(currentPosition: Int) {
if (data.size > 1) {
rightBtn.visibility = if (currentPosition == data.size - 1) View.GONE else View.VISIBLE
leftBtn.visibility = if (currentPosition == 0) View.GONE else View.VISIBLE
}
initLevelState(currentItem)
}
private fun initLevelState(currentItem: TherapyPackage?) {
if (currentItem!!.therapyLevels.size >= 2) {
if (currentItem.activeTherapyPackageLevelId == currentItem.therapyLevels.minBy { it.id }?.id) {
levelDown.isEnabled = false
levelDown.alpha = 0.8f
} else {
levelDown.isEnabled = true
levelDown.alpha = 1f
}
} else {
levelDown.isEnabled = false
levelDown.alpha = 0.8f
}
}
override fun setData(data: List<TherapyPackage>) {
this.data = data
if (data.isNotEmpty())
currentItem = if (currentItem != null) {
data.firstOrNull { it.therapyPackageId == currentItem?.therapyPackageId }
?: data.first()
} else {
data.first()
}
viewPager.adapter?.notifyDataSetChanged()
currentItem?.let { initLevelState(currentItem) }
}
override fun setExerciseTime(sec: Int) {
time = sec
timer.text = sec.toString()
}
override fun getExerciseTime(): Int {
return time
}
override fun onDestroyView() {
super.onDestroyView()
presenter.saveTime()
}
override fun moveToScreen(screen: String, data: Bundle) {
router.newRootScreen(screen, data)
}
override fun startLevelUp(therapyPackage: TherapyPackage) {
startActivityForResult(Intent(context, DiagnosticActivity::class.java).putExtra(DiagnosticActivity.ACTION, ACTION_LEVEL_UP).putExtra(ACTION_LEVEL_UP, therapyPackage.therapyPackageId), DiagnosticActivity.REQUEST_CODE)
}
override fun showLevelUpDialog(therapyPackage: TherapyPackage, confirm: Boolean) {
CustomAlertDialogBuilder(context)
.setTitle(R.string.therapy_improvement)
.setBackground(R.drawable.dialog_white_background)
.setTextColor(Color.parseColor("#0000ff"))
.addMessage(if (confirm) getString(R.string.start_level_up, therapyPackage.title?.getText)
else getString(R.string.level_up_message_not_confirmed))
.setPositiveButton(if (confirm) R.string.progress_action_yes else R.string.positive_not_confirm_level_up, object : CustomAlertDialogBuilder.OnItemDialogClickListener {
override fun onClick(dialog: CustomAlertDialogBuilder.CustomDialogInterface) {
presenter.startLevelUp(therapyPackage)
dialog.dismiss()
}
})
.setNegativeButton(if (confirm) R.string.no else R.string.negative_not_confirm_level_up, object : CustomAlertDialogBuilder.OnItemDialogClickListener {
override fun onClick(dialog: CustomAlertDialogBuilder.CustomDialogInterface) {
dialog.dismiss()
}
}).build()?.show()
}
override fun levelDown(therapyPackage: TherapyPackage) {
showMessage(getString(R.string.level_down, therapyPackage.title?.getText))
}
override fun levelUp(therapyPackage: TherapyPackage) {
showMessage(getString(R.string.level_up, therapyPackage.title?.getText))
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
presenter.getPackages()
}
}