@@ -6,7 +6,6 @@ import com.adamratzman.spotify.http.SpotifyEndpoint
6
6
import com.adamratzman.spotify.models.serialization.toCursorBasedPagingObject
7
7
import com.adamratzman.spotify.models.serialization.toPagingObject
8
8
import com.adamratzman.spotify.utils.runBlocking
9
- import kotlin.reflect.KClass
10
9
import kotlinx.coroutines.Dispatchers
11
10
import kotlinx.coroutines.ExperimentalCoroutinesApi
12
11
import kotlinx.coroutines.flow.Flow
@@ -18,6 +17,7 @@ import kotlinx.coroutines.flow.toList
18
17
import kotlinx.serialization.SerialName
19
18
import kotlinx.serialization.Serializable
20
19
import kotlinx.serialization.Transient
20
+ import kotlin.reflect.KClass
21
21
22
22
/*
23
23
Types used in PagingObjects and CursorBasedPagingObjects:
@@ -209,7 +209,7 @@ abstract class AbstractPagingObject<T : Any>(
209
209
@Transient open val offset : Int = 0 ,
210
210
@Transient open val previous : String? = null ,
211
211
@Transient open val total : Int = -1
212
- ) : List<T> by items {
212
+ ) : List<T> {
213
213
@Transient
214
214
internal var endpoint: SpotifyEndpoint ? = null
215
215
@@ -262,6 +262,22 @@ abstract class AbstractPagingObject<T : Any>(
262
262
263
263
@ExperimentalCoroutinesApi
264
264
fun flowEndOrdered (): Flow <AbstractPagingObject <T >> = flowForward()
265
+
266
+
267
+ // A paging object is also a list, and instantiation by deserialization doesn't properly store the items list internally
268
+ // so we implement list methods
269
+
270
+ override val size: Int get() = items.size
271
+ override fun contains (element : T ) = items.contains(element)
272
+ override fun containsAll (elements : Collection <T >) = items.containsAll(elements)
273
+ override fun get (index : Int ) = items[index]
274
+ override fun indexOf (element : T ) = items.indexOf(element)
275
+ override fun isEmpty () = items.isEmpty()
276
+ override fun iterator () = items.iterator()
277
+ override fun lastIndexOf (element : T ) = items.lastIndexOf(element)
278
+ override fun listIterator () = items.listIterator()
279
+ override fun listIterator (index : Int ) = items.listIterator(index)
280
+ override fun subList (fromIndex : Int , toIndex : Int ) = items.subList(fromIndex, toIndex)
265
281
}
266
282
267
283
internal fun Any.instantiatePagingObjects (spotifyApi : SpotifyApi <* , * >) = when (this ) {
0 commit comments