Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.shellmonger.apps.mynotes.repositories.datasources
- import android.arch.paging.DataSource
- import android.arch.paging.ItemKeyedDataSource
- import android.util.Log
- import com.shellmonger.apps.mynotes.models.Note
- class MockNotesDataSource : ItemKeyedDataSource<Int, Note>() {
- companion object {
- private val TAG = this::class.java.simpleName
- const val MAX_PAGE_SIZE = 20
- }
- /**
- * The list of items in the data source
- */
- private val items: MutableList<Note> = ArrayList()
- init {
- // Create some fake data
- for (i in 0..200) {
- items.add(Note().apply { title = "title $i"; content = "content $i" })
- }
- }
- fun inRange(position: Int, start: Int, end: Int): Int {
- if (position < start) return start
- if (position > end) return end
- return position
- }
- // Other methods here
- }
Add Comment
Please, Sign In to add comment