Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package jp.co.marginal.demo.model
  2.  
  3. import android.content.res.Resources
  4. import jp.co.marginal.demo.R
  5. import jp.co.marginal.demo.extension.getResourceIdList
  6.  
  7. /**
  8. * Albums Service
  9. */
  10. class AlbumsService(private val resources: Resources) {
  11.  
  12. /**
  13. * albums
  14. */
  15. val albums: List<Album> = {
  16. val ids = resources.getIntArray(R.array.album_ids)
  17. val images = resources.obtainTypedArray(R.array.album_images).getResourceIdList()
  18. val titles = resources.getStringArray(R.array.album_titles)
  19. assert(ids.size == images.size && images.size == titles.size, {"size does not match"})
  20. ids.mapIndexed { i, id -> Album(id, images[i], titles[i]) }
  21. }()
  22.  
  23. }
  24.  
  25. data class Album(val id: Int, val imageResourceId: Int, val title: String)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement