Last active
August 13, 2016 10:18
-
-
Save travisdachi/dd4821221912ed2f9b148486d6e36201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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