Guest User

Untitled

a guest
May 20th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package com.shellmonger.apps.mynotes.repositories.datasources
  2.  
  3. import android.arch.paging.DataSource
  4. import android.arch.paging.ItemKeyedDataSource
  5. import android.util.Log
  6. import com.shellmonger.apps.mynotes.models.Note
  7.  
  8. class MockNotesDataSource : ItemKeyedDataSource<Int, Note>() {
  9. companion object {
  10. private val TAG = this::class.java.simpleName
  11.  
  12. const val MAX_PAGE_SIZE = 20
  13. }
  14.  
  15. /**
  16. * The list of items in the data source
  17. */
  18. private val items: MutableList<Note> = ArrayList()
  19.  
  20. init {
  21. // Create some fake data
  22. for (i in 0..200) {
  23. items.add(Note().apply { title = "title $i"; content = "content $i" })
  24. }
  25. }
  26.  
  27. fun inRange(position: Int, start: Int, end: Int): Int {
  28. if (position < start) return start
  29. if (position > end) return end
  30. return position
  31. }
  32.  
  33. // Other methods here
  34. }
Add Comment
Please, Sign In to add comment