hi everyone i have problem this my code and i but the logd under see that , the problem is the zigzag true and fromfirst false and that normal to work but the code say select one from this two chooise and i say that one true and another one is false the app exit when i click on the button how to fix that
Not: the code was in java and i convert to kotlin in java he was work but here not work
(`_$_findCachedViewById`(R.id.btn_Submit) as Button).setOnClickListener(
View.OnClickListener
// android.view.View.OnClickListener
{
Log.d("TAG", "aly listeners: click inside")
try {
val SleepTime = `_$_findCachedViewById`(R.id.SleepTime) as SeekBar
Log.d("TAG", "aly listeners: SleepTime $SleepTime")
Log.d("TAG", "aly listeners: SleepTime progress ${SleepTime.progress}")
val bluetooth = SharedPref.getInstance(this@MainActivity).getStringData("Bluetooth", "off")
Log.d("TAG", "aly listeners: bluetooth $bluetooth")
val otg = SharedPref.getInstance(this@MainActivity).getStringData("OTG", "off")
Log.d("TAG", "aly listeners: otg $otg")
Intrinsics.checkExpressionValueIsNotNull(SleepTime, "SleepTime")
Log.d("TAG", "aly listeners: intrinsics 1 ${Intrinsics.checkExpressionValueIsNotNull(SleepTime, "SleepTime")}")
if (bluetooth.equals("on") || otg.equals("on")) {
Log.d("TAG", "aly listeners: first if ${Intrinsics.areEqual(bluetooth, "on") || Intrinsics.areEqual(otg, "on")}")
if (!SleepTime.progress.equals(0)) {
Log.d("TAG", "aly listeners: sec if ${!Intrinsics.areEqual(SleepTime.progress, 0)}")
val PalsPerColumn = `_$_findCachedViewById`(R.id.PalsPerColumn) as SeekBar
Log.d("TAG", "aly listeners: PalsPerColumn $PalsPerColumn")
Log.d("TAG", "aly listeners: PalsPerColumn progress ${PalsPerColumn.progress}")
Intrinsics.checkExpressionValueIsNotNull(PalsPerColumn, "PalsPerColumn")
Log.d("TAG", "aly listeners: intrinsics 2 ${Intrinsics.checkExpressionValueIsNotNull(PalsPerColumn, "PalsPerColumn")}")
val PalsPerRow = `_$_findCachedViewById`(R.id.PalsPerRow) as SeekBar
Log.d("TAG", "aly listeners: PalsPerRow $PalsPerRow")
Log.d("TAG", "aly listeners: PalsPerRow progress ${PalsPerRow.progress}")
Intrinsics.checkExpressionValueIsNotNull(PalsPerRow, "PalsPerRow")
Log.d("TAG", "aly listeners: intrinsics 3 ${Intrinsics.checkExpressionValueIsNotNull(PalsPerRow, "PalsPerRow")}")
if ((!PalsPerColumn.progress.equals(0)) && (!PalsPerRow.progress.equals(0))) {
Log.d("TAG", "aly listeners: third if ${(!Intrinsics.areEqual(PalsPerColumn.progress, 0)) && (!Intrinsics.areEqual(PalsPerRow.progress, 0))}")
val palsOrientation = `_$_findCachedViewById`(R.id.palsOrientation) as RadioGroup
Log.d("TAG", "aly listeners: palsOrientation $palsOrientation")
Intrinsics.checkExpressionValueIsNotNull(palsOrientation, "palsOrientation")
Log.d("TAG", "aly listeners: intrinsics 4 ${Intrinsics.checkExpressionValueIsNotNull(palsOrientation, "palsOrientation")}")
val zigzag = `_$_findCachedViewById`(R.id.zigzag) as RadioButton
Log.d("TAG", "aly listeners: zigzag $zigzag")
Log.d("TAG", "aly listeners: zigzag isChecked ${zigzag.isChecked}")
val fromFirst = `_$_findCachedViewById`(R.id.fromFirst) as RadioButton
Log.d("TAG", "aly listeners: fromFirst $fromFirst")
Log.d("TAG", "aly listeners: fromFirst isChecked ${fromFirst.isChecked}")
try {
if (fromFirst.isChecked || zigzag.isChecked) {
Log.d("TAG", "aly listeners: orientation selected")
if ((!fromFirst.isChecked) || (!zigzag.isChecked)) {
Log.d(
"TAG",
"aly listeners: fromFirst isChecked ${fromFirst.isChecked}," +
" zigzag isChecked ${zigzag.isChecked}"
)
Log.d("TAG", "aly listeners: orientation not selected")
val errors =
`_$_findCachedViewById`(R.id.errors) as TextView
errors.visibility = View.VISIBLE
errors.text = "Please select one of Scan Orientations"
return@OnClickListener
}
[email protected]("surface")
[email protected]()
val main =
`_$_findCachedViewById`(R.id.main) as LinearLayout
main.visibility = View.VISIBLE
val setting =
`_$_findCachedViewById`(R.id.setting) as LinearLayout
setting.visibility = View.GONE
return@OnClickListener
}
val errors = `_$_findCachedViewById`(R.id.errors) as TextView
Log.d("TAG", "aly listeners: errors $errors")
errors.visibility = View.VISIBLE
errors.text = "Please select one of Scan Orientations"
return@OnClickListener
}catch (e:Exception){
Log.d("TAG", "aly listeners: $e")
}
}
}
val errors3 = `_$_findCachedViewById`(R.id.errors) as TextView
Log.d("TAG", "aly listeners: errors3 $errors3")
errors3.visibility = View.VISIBLE
errors3.text = "All fields must be completed"
} else {
Log.d("TAG", "aly listeners: Bluetooth or OTG OFF")
Alerts.show_alert(
this@MainActivity,
getString(R.string.not_connected),
getString(R.string.choose_connection_method)
)
}
} catch (e: Exception) {
e.printStackTrace()
Log.d("TAG", "aly listeners: Exception caught: $e")
}
})
this logd
2024-09-08 14:07:05.694 aly listeners: click inside
2024-09-08 14:07:05.695 aly listeners: SleepTime
2024-09-08 14:07:05.695 aly listeners: SleepTime progress 1
2024-09-08 14:07:05.695 aly listeners: bluetooth on
2024-09-08 14:07:05.695 aly listeners: otg off
2024-09-08 14:07:05.695 aly listeners: intrinsics 1 kotlin.Unit
2024-09-08 14:07:05.695 aly listeners: first if true
2024-09-08 14:07:05.695 aly listeners: sec if true
2024-09-08 14:07:05.696 aly listeners: PalsPerColumn
2024-09-08 14:07:05.697 aly listeners: PalsPerColumn progress 2
2024-09-08 14:07:05.697 aly listeners: intrinsics 2 kotlin.Unit
2024-09-08 14:07:05.698 aly listeners: PalsPerRow
2024-09-08 14:07:05.698 aly listeners: PalsPerRow progress 2
2024-09-08 14:07:05.698 aly listeners: intrinsics 3 kotlin.Unit
2024-09-08 14:07:05.698 aly listeners: third if true
2024-09-08 14:07:05.699 aly listeners: palsOrientation
2024-09-08 14:07:05.699 aly listeners: intrinsics 4 kotlin.Unit
2024-09-08 14:07:05.700 aly listeners: zigzag
2024-09-08 14:07:05.700 aly listeners: zigzag isChecked true
2024-09-08 14:07:05.701 aly listeners: fromFirst
2024-09-08 14:07:05.701 aly listeners: fromFirst isChecked false
2024-09-08 14:07:05.701 aly listeners: orientation selected
2024-09-08 14:07:05.701 aly listeners: fromFirst isChecked false, zigzag isChecked true
2024-09-08 14:07:05.701 aly listeners: orientation not selected
2024-09-08 14:07:09.852 aly listeners: click inside
2024-09-08 14:07:09.853 aly listeners: SleepTime
2024-09-08 14:07:09.853 aly listeners: SleepTime progress 1
2024-09-08 14:07:09.853 aly listeners: bluetooth on
2024-09-08 14:07:09.853 aly listeners: otg off
2024-09-08 14:07:09.853 aly listeners: intrinsics 1 kotlin.Unit
2024-09-08 14:07:09.853 aly listeners: first if true
2024-09-08 14:07:09.853 aly listeners: sec if true
2024-09-08 14:07:09.854 aly listeners: PalsPerColumn
2024-09-08 14:07:09.854 aly listeners: PalsPerColumn progress 2
2024-09-08 14:07:09.854 aly listeners: intrinsics 2 kotlin.Unit
2024-09-08 14:07:09.854 aly listeners: PalsPerRow
2024-09-08 14:07:09.854 aly listeners: PalsPerRow progress 2
2024-09-08 14:07:09.854 aly listeners: intrinsics 3 kotlin.Unit
2024-09-08 14:07:09.855 aly listeners: third if true
2024-09-08 14:07:09.855 aly listeners: palsOrientation
2024-09-08 14:07:09.855 aly listeners: intrinsics 4 kotlin.Unit
2024-09-08 14:07:09.856 aly listeners: zigzag
2024-09-08 14:07:09.856 aly listeners: zigzag isChecked true
2024-09-08 14:07:09.856 aly listeners: fromFirst
2024-09-08 14:07:09.856 aly listeners: fromFirst isChecked false
2024-09-08 14:07:09.856 aly listeners: orientation selected
2024-09-08 14:07:09.856 aly listeners: fromFirst isChecked false, zigzag isChecked true
2024-09-08 14:07:09.856 aly listeners: orientation not selected