-
-
Save passsy/34f99d5a57e331e872b88cc1fae25dc0 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
class UserDetailActivity : Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val userId = intent.getStringExtra(INTENT_USER_ID) | |
?: throw IllegalStateException("field $INTENT_USER_ID missing in Intent") | |
} | |
companion object { | |
private val INTENT_USER_ID = "user_id" | |
fun newIntent(context: Context, user: User): Intent { | |
val intent = Intent(context, UserDetailActivity::class.java) | |
intent.putExtra(INTENT_USER_ID, user.id) | |
return intent | |
} | |
} | |
} |
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
class OtherActivity : Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
//... | |
userlist.clickListener { user -> | |
val intent = UserDetailActivity.newIntent(this, user) | |
startActivity(intent) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment