Last active
April 3, 2018 21:38
-
-
Save malwinder-s/9147a2b78daa18150511f11ae7a393c6 to your computer and use it in GitHub Desktop.
Example of non boilerplate code
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
private fun launch(id: String, name: String, totalScore: Int, className: Class) { | |
val intent = Intent(this, className) | |
intent.replaceExtras(getExtras(id, name, totalScore)) | |
startActivity(intent) | |
} | |
private fun getExtras(id: String, name: String, totalScore: Int): Bundle { | |
val extras = Bundle() | |
extras.putString(EXTRA_STUDENT_ID, id) | |
extras.putString(EXTRA_STUDENT_NAME, name) | |
//Suppose "totalScore" is score of student in 5 subjects. | |
val totalPercentage = totalScore / 5 | |
extras.putString(EXTRA_STUDENT_PERCENTAGE, totalPercentage) | |
return extras | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment