-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/deploy-springboot-cd
- Loading branch information
Showing
69 changed files
with
4,526 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
android/app/src/main/java/com/goliath/emojihub/EmojiHubApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
android/app/src/main/java/com/goliath/emojihub/data_sources/EmojiPagingSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.goliath.emojihub.data_sources | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.goliath.emojihub.data_sources.api.EmojiApi | ||
import com.goliath.emojihub.models.EmojiDto | ||
import javax.inject.Inject | ||
|
||
class EmojiPagingSource @Inject constructor( | ||
private val api: EmojiApi | ||
): PagingSource<Int, EmojiDto>() { | ||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, EmojiDto> { | ||
val cursor = params.key ?: 1 | ||
val count = params.loadSize | ||
return try { | ||
val response = api.fetchEmojiList(1, cursor, count).body() | ||
val data = response ?: listOf() | ||
LoadResult.Page( | ||
data = data, | ||
prevKey = if (cursor == 1) null else cursor - 1, | ||
nextKey = if (data.isEmpty()) null else cursor + 1 | ||
) | ||
} catch (exception: Exception) { | ||
LoadResult.Error(exception) | ||
} | ||
} | ||
|
||
override fun getRefreshKey(state: PagingState<Int, EmojiDto>): Int? { | ||
return state.anchorPosition?.let { anchorPosition -> | ||
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1) | ||
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.