Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
8cd3b603
Commit
8cd3b603
authored
May 25, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed cached repos not being ordered by settings
parent
6e1aefe6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
RepositoryDao.kt
.../java/com/topjohnwu/magisk/data/database/RepositoryDao.kt
+4
-1
ModuleRepository.kt
.../com/topjohnwu/magisk/data/repository/ModuleRepository.kt
+10
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/data/database/RepositoryDao.kt
View file @
8cd3b603
...
@@ -13,7 +13,10 @@ interface RepositoryDao : BaseDao<Repository> {
...
@@ -13,7 +13,10 @@ interface RepositoryDao : BaseDao<Repository> {
@Transaction
@Transaction
override
fun
deleteAll
()
override
fun
deleteAll
()
@Query
(
"SELECT * FROM repos"
)
@Query
(
"SELECT * FROM repos
ORDER BY lastUpdate DESC
"
)
override
fun
fetchAll
():
List
<
Repository
>
override
fun
fetchAll
():
List
<
Repository
>
@Query
(
"SELECT * FROM repos ORDER BY name ASC"
)
fun
fetchAllOrderByName
():
List
<
Repository
>
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/data/repository/ModuleRepository.kt
View file @
8cd3b603
package
com.topjohnwu.magisk.data.repository
package
com.topjohnwu.magisk.data.repository
import
android.content.Context
import
android.content.Context
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.data.database.RepositoryDao
import
com.topjohnwu.magisk.data.database.RepositoryDao
import
com.topjohnwu.magisk.data.network.GithubApiServices
import
com.topjohnwu.magisk.data.network.GithubApiServices
import
com.topjohnwu.magisk.data.network.GithubRawApiServices
import
com.topjohnwu.magisk.data.network.GithubRawApiServices
...
@@ -23,7 +24,7 @@ class ModuleRepository(
...
@@ -23,7 +24,7 @@ class ModuleRepository(
)
{
)
{
fun
fetchModules
(
force
:
Boolean
=
false
)
=
fun
fetchModules
(
force
:
Boolean
=
false
)
=
if
(
force
)
fetchRemoteRepos
()
else
Single
.
fromCallable
{
repoDao
.
fetchAll
()
}
if
(
force
)
fetchRemoteRepos
()
else
fetchCachedOrdered
()
.
flatMap
{
if
(
it
.
isEmpty
())
fetchRemoteRepos
()
else
it
.
toSingle
()
}
.
flatMap
{
if
(
it
.
isEmpty
())
fetchRemoteRepos
()
else
it
.
toSingle
()
}
private
fun
fetchRemoteRepos
()
=
fetchAllRepos
()
private
fun
fetchRemoteRepos
()
=
fetchAllRepos
()
...
@@ -36,6 +37,14 @@ class ModuleRepository(
...
@@ -36,6 +37,14 @@ class ModuleRepository(
}
}
.
doOnSuccess
{
repoDao
.
insert
(
it
)
}
.
doOnSuccess
{
repoDao
.
insert
(
it
)
}
private
fun
fetchCachedOrdered
()
=
Single
.
fromCallable
{
when
(
Config
.
get
<
Int
>(
Config
.
Key
.
REPO_ORDER
))
{
Config
.
Value
.
ORDER_DATE
->
repoDao
.
fetchAll
()
Config
.
Value
.
ORDER_NAME
->
repoDao
.
fetchAllOrderByName
()
else
->
repoDao
.
fetchAll
()
}
}
fun
fetchInstalledModules
()
=
Single
.
fromCallable
{
Utils
.
loadModulesLeanback
()
}
fun
fetchInstalledModules
()
=
Single
.
fromCallable
{
Utils
.
loadModulesLeanback
()
}
.
map
{
it
.
values
.
toList
()
}
.
map
{
it
.
values
.
toList
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment