|
| 1 | +import android.app.Activity |
| 2 | +import android.content.Intent |
| 3 | +import android.net.Uri |
| 4 | +import androidx.activity.result.contract.ActivityResultContract |
| 5 | + |
| 6 | +// package com.into.websoso.core.database.datasource.library |
| 7 | +// |
| 8 | +// import androidx.paging.PagingSource |
| 9 | +// import androidx.paging.PagingState |
| 10 | +// import com.into.websoso.core.database.entity.InDatabaseNovelEntity |
| 11 | +// import com.into.websoso.data.library.model.NovelEntity |
| 12 | +// |
| 13 | +// internal class NovelEntityPagingSource( |
| 14 | +// private val source: PagingSource<Int, InDatabaseNovelEntity>, |
| 15 | +// ) : PagingSource<Int, NovelEntity>() { |
| 16 | +// override suspend fun load(params: LoadParams<Int>): LoadResult<Int, NovelEntity> = |
| 17 | +// when (val result = source.load(params)) { |
| 18 | +// is LoadResult.Page -> LoadResult.Page( |
| 19 | +// data = result.data.map(InDatabaseNovelEntity::toData), |
| 20 | +// prevKey = result.prevKey, |
| 21 | +// nextKey = result.nextKey, |
| 22 | +// ) |
| 23 | +// |
| 24 | +// is LoadResult.Error -> LoadResult.Error(result.throwable) |
| 25 | +// is LoadResult.Invalid -> LoadResult.Invalid() |
| 26 | +// } |
| 27 | +// |
| 28 | +// override fun getRefreshKey(state: PagingState<Int, NovelEntity>): Int? { |
| 29 | +// val anchorPosition = state.anchorPosition ?: return null |
| 30 | +// val novel = state.closestItemToPosition(anchorPosition) ?: return null |
| 31 | +// return novel.userNovelId.toInt() |
| 32 | +// } |
| 33 | +// } |
| 34 | + |
0 commit comments