View gist:dd76398a70a12ead428c20f89e51a29c
private fun initAdapter() { | |
adapter.addLoadStateListener { loadState -> | |
// Only show the list if refresh succeeds. | |
binding.list.isVisible = loadState.source.refresh is LoadState.NotLoading | |
// Show loading spinner during initial load or refresh. | |
binding.progressBar.isVisible = loadState.source.refresh is LoadState.Loading | |
// Show the retry state if initial load or refresh fails. | |
binding.retryButton.isVisible = loadState.source.refresh is LoadState.Error | |
} | |
} |
View patch.diff
diff --git a/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt b/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt | |
index 81b3b8d..7529c8a 100644 | |
--- a/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt | |
+++ b/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt | |
@@ -42,7 +42,7 @@ class GithubRepository( | |
// appending '%' so we can allow other characters to be before and after the query string | |
val dbQuery = "%${query.replace(' ', '%')}%" | |
- val pagingSourceFactory = { database.reposDao().reposByName(dbQuery) } | |
+ val pagingSourceFactory = { database.reposDao().reposByIdx(dbQuery) } |
View gist:32198097ba4ba4f402ceafb284ea28f1
+---------+--------------+---------+ | |
| prev: 0 | repo 001 | next: 2 | | |
+---------+--------------+---------+ | |
| prev: 1 | repo 087 | next: 3 | | |
+---------+--------------+---------+ | |
| prev: 0 | repo 002 | next: 2 | | |
+---------+--------------+---------+ | |
... | |
+---------+--------------+---------+ | |
| prev: 1 | repo 056 | next: 3 | |
View gist:a68e0e9249477d11521695ade285fc3e
+---------+--------------+---------+ | |
| prev: 0 | repo 001 | next: 2 | | |
+---------+--------------+---------+ | |
| prev: 0 | repo 002 | next: 2 | | |
+---------+--------------+---------+ | |
| prev: 0 | repo 003 | next: 2 | | |
+---------+--------------+---------+ | |
... | |
+---------+--------------+---------+ | |
| prev: 0 | repo 048 | next: 2 | |
View RepoDao.kt
interface RepoDao { | |
@Query("SELECT * FROM repos WHERE " + | |
"name LIKE :queryString OR description LIKE :queryString " + | |
"ORDER BY stars DESC, name ASC") | |
fun reposByName(queryString: String): PagingSource<Int, Repo> | |
} |
View GithubRepository.kt
class GithubRepository { | |
fun getSearchResultStream(query: String): Flow<PagingData<Repo>> { | |
val dbQuery = "%${query.replace(' ', '%')}%" | |
val pagingSourceFactory = { database.reposDao().reposByName(dbQuery)} | |
return Pager( | |
config = PagingConfig(pageSize = NETWORK_PAGE_SIZE, enablePlaceholders = false), | |
remoteMediator = GithubRemoteMediator(query, service, database), | |
pagingSourceFactory = pagingSourceFactory | |
).flow |
View GithubService.kt
interface GithubService { | |
/** | |
* Get repos ordered by stars. | |
*/ | |
@GET("search/repositories?sort=stars") | |
suspend fun searchRepos( | |
@Query("q") query: String, | |
@Query("page") page: Int, | |
@Query("per_page") itemsPerPage: Int | |
): RepoSearchResponse |
View gist:17ec323667c5b2abca1e3ff74af195bf
diff --git a/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt b/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt | |
index 16ac44a..61d77ca 100644 | |
--- a/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt | |
+++ b/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt | |
@@ -55,7 +55,11 @@ class SearchRepositoriesViewModel(private val repository: GithubRepository) : Vi | |
if (before == null) { | |
// we're at the beginning of the list | |
- return@insertSeparators UiModel.SeparatorItem("${after.roundedStarCount}0.000+ stars") | |
+ if (after.roundedStarCount >= 1) { |
View README
* Download magisk.zip and unzip | |
* Rename x86/magiskboot to x86/magiskboot.real | |
* Add x86/magiskboot | |
* Add x86/mboot (https://github.com/shakalaca/MagiskOnIntelDevices/raw/master/mboot) | |
* ZIP and update from MagiskManager custom channel (modify https://raw.githubusercontent.com/topjohnwu/magisk_files/canary/debug.json) |
View 2-mount
# | |
# By Chih-Wei Huang <cwhuang@linux.org.tw> | |
# Last updated 2017/04/23 | |
# | |
# License: GNU Public License | |
# We explicitely grant the right to use the scripts | |
# with Android-x86 project. | |
# | |
mount_data() |
NewerOlder