2

Jul 05 6:23 AM - Codeshare

 2 years ago
source link: https://codeshare.io/BApxRy
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Jul 05 6:23 AM

xxxxxxxxxx
package com.naufaldystd.core.data.source.paging
import androidx.paging.ExperimentalPagingApi
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.naufaldystd.core.data.source.local.entity.GameEntity
import com.naufaldystd.core.data.source.local.room.RawgDatabase
import com.naufaldystd.core.data.source.remote.response.GameResponse
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class GamePagingRepository @Inject constructor(
    private val database: RawgDatabase,
    private val gamePagingMediator: GamePagingMediator
//    private val gamePagingSource: GamePagingSource
) : IGameRepository {
    @OptIn(ExperimentalPagingApi::class)
    override suspend fun getGamePaging(): Flow<PagingData<GameEntity>> {
        return Pager(
            config = PagingConfig(
                pageSize = 20,
                enablePlaceholders = false,
                prefetchDistance = 5,
                initialLoadSize = 40
            ),
            remoteMediator = gamePagingMediator,
            pagingSourceFactory = {database.rawgDao().getPagingGame()}
        ) .flow
    }
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK