Created
February 20, 2018 13:50
-
-
Save pandulapeter/455d5ab609868cf036625f8fd15b580c to your computer and use it in GitHub Desktop.
Example usage of BundleDelegate
This file contains hidden or 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 MusicPlayerFragment : Fragment() { | |
private val playlistId by lazy { arguments.playlistId } | |
private val songIndex by lazy { arguments.songIndex } | |
companion object { | |
private var Bundle.playlistId by BundleDelegate.String("key_playlist_id") | |
private var Bundle.songIndex by BundleDelegate.Int("key_song_index") | |
fun newInstance(playlistId: String, songIndex: Int) = MusicPlayerFragment().apply { | |
arguments = Bundle().apply { | |
this.playlistId = playlistId | |
this.songIndex = songIndex | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment