Skip to content

Instantly share code, notes, and snippets.

@NikolaDespotoski
Last active March 31, 2020 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolaDespotoski/592a59e894aafb7c08ceef45e76a253b to your computer and use it in GitHub Desktop.
Save NikolaDespotoski/592a59e894aafb7c08ceef45e76a253b to your computer and use it in GitHub Desktop.
@FragmentScope
class ChooseFilterContractor @Inject constructor(private val context: Context) : ActivityResultContractor<Unit, String> {
  override fun createIntent(input: Unit): Intent = Intent(context, ChooseFilterActivity::class.java)
 
override fun parseResult(resultCode: Int, intent: Intent?): String = if (resultCode == Activity.RESULT_OK) {
 intent?.getStringExtra(KEY_FILTER)?: error("Dispatched RESULT_OK, but no payload)
 } else {
 ""
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment