Skip to content

Instantly share code, notes, and snippets.

@travisdachi
Last active August 13, 2016 10:18
Show Gist options
  • Save travisdachi/dd4821221912ed2f9b148486d6e36201 to your computer and use it in GitHub Desktop.
Save travisdachi/dd4821221912ed2f9b148486d6e36201 to your computer and use it in GitHub Desktop.
import kotlinx.android.synthetic.main.activity_legendary_grader.*
class LegendaryGraderActivity : AppCompatActivity() {
var grader: Grader = TypicalGrader()
val satisfy = 50
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_legendary_grader)
act_grader_imageButton.setOnClickListener { view ->
val s = act_grader_editText.text.toString()
if (s.isNotBlank()) {
try {
val i = s.toInt()
act_grader_editText.setText("")
act_grader_textView.text = grader.grade(i)
} catch (e: NumberFormatException) {
Toast.makeText(this, "Hey! $s is not an Int", Toast.LENGTH_SHORT).show()
}
}
}
act_grader_radioGroup.setOnCheckedChangeListener { radioGroup, checkedId ->
when (checkedId) {
R.id.act_grader_radio_typical -> grader = TypicalGrader()
R.id.act_grader_radio_su -> grader = SuGrader(satisfy)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment