Diego Almeida de Oliveira
12/17/2019, 3:16 PMinterface IntentInterface {
fun getStringExtra(name: String?): String
fun getIntExtra(name: String?): Int
...
}
class CustomIntent : Intent, IntentInterface {
constructor() : super()
constructor(intent: Intent?) : super(intent)
constructor(packageContext: Context?, cls: Class<*>?) : super(packageContext, cls)
...
}
class SampleActivity: AppCompatActivity() {
...
fun handleIntent() {
viewModel.processReceivedData(CustomIntent(intent))
}
...
}
class SampleViewModel: ViewModel() {
...
fun processReceivedData(data: IntentInterface) {
val sampleValue = data.getStringExtra("sample_key")
...
}
...
}
wasyl
12/17/2019, 8:56 PMwasyl
12/17/2019, 8:57 PMIsaac Udy
12/18/2019, 5:31 AMDmitry Khasanov
12/18/2019, 10:48 AM