Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jp.co.marginal.demo.model
- import android.content.res.Resources
- import jp.co.marginal.demo.R
- import jp.co.marginal.demo.extension.getResourceIdList
- /**
- * Albums Service
- */
- class AlbumsService(private val resources: Resources) {
- /**
- * albums
- */
- val albums: List<Album> = {
- val ids = resources.getIntArray(R.array.album_ids)
- val images = resources.obtainTypedArray(R.array.album_images).getResourceIdList()
- val titles = resources.getStringArray(R.array.album_titles)
- assert(ids.size == images.size && images.size == titles.size, {"size does not match"})
- ids.mapIndexed { i, id -> Album(id, images[i], titles[i]) }
- }()
- }
- data class Album(val id: Int, val imageResourceId: Int, val title: String)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement