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
027a5695
Commit
027a5695
authored
Nov 11, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added progressbars to repo items
parent
d6d82edf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
ModuleRvItem.kt
...om/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt
+2
-0
ModuleViewModel.kt
...a/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt
+22
-0
item_repo_md2.xml
app/src/main/res/layout/item_repo_md2.xml
+19
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt
View file @
027a5695
...
@@ -102,6 +102,8 @@ class RepoItem(val item: Repo) : ComparableRvItem<RepoItem>() {
...
@@ -102,6 +102,8 @@ class RepoItem(val item: Repo) : ComparableRvItem<RepoItem>() {
override
val
layoutRes
:
Int
=
R
.
layout
.
item_repo_md2
override
val
layoutRes
:
Int
=
R
.
layout
.
item_repo_md2
val
progress
=
KObservableField
(
0
)
override
fun
contentSameAs
(
other
:
RepoItem
):
Boolean
=
item
==
other
.
item
override
fun
contentSameAs
(
other
:
RepoItem
):
Boolean
=
item
==
other
.
item
override
fun
itemSameAs
(
other
:
RepoItem
):
Boolean
=
item
.
id
==
other
.
item
.
id
override
fun
itemSameAs
(
other
:
RepoItem
):
Boolean
=
item
.
id
==
other
.
item
.
id
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/redesign/module/ModuleViewModel.kt
View file @
027a5695
...
@@ -10,12 +10,15 @@ import com.topjohnwu.magisk.data.database.RepoByNameDao
...
@@ -10,12 +10,15 @@ import com.topjohnwu.magisk.data.database.RepoByNameDao
import
com.topjohnwu.magisk.data.database.RepoByUpdatedDao
import
com.topjohnwu.magisk.data.database.RepoByUpdatedDao
import
com.topjohnwu.magisk.databinding.ComparableRvItem
import
com.topjohnwu.magisk.databinding.ComparableRvItem
import
com.topjohnwu.magisk.extensions.subscribeK
import
com.topjohnwu.magisk.extensions.subscribeK
import
com.topjohnwu.magisk.model.download.RemoteFileService
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.entity.module.Module
import
com.topjohnwu.magisk.model.entity.module.Module
import
com.topjohnwu.magisk.model.entity.module.Repo
import
com.topjohnwu.magisk.model.entity.module.Repo
import
com.topjohnwu.magisk.model.entity.recycler.LoadingItem
import
com.topjohnwu.magisk.model.entity.recycler.LoadingItem
import
com.topjohnwu.magisk.model.entity.recycler.ModuleItem
import
com.topjohnwu.magisk.model.entity.recycler.ModuleItem
import
com.topjohnwu.magisk.model.entity.recycler.RepoItem
import
com.topjohnwu.magisk.model.entity.recycler.RepoItem
import
com.topjohnwu.magisk.model.entity.recycler.SectionTitle
import
com.topjohnwu.magisk.model.entity.recycler.SectionTitle
import
com.topjohnwu.magisk.model.events.dialog.ModuleInstallDialog
import
com.topjohnwu.magisk.redesign.compat.CompatViewModel
import
com.topjohnwu.magisk.redesign.compat.CompatViewModel
import
com.topjohnwu.magisk.redesign.home.itemBindingOf
import
com.topjohnwu.magisk.redesign.home.itemBindingOf
import
com.topjohnwu.magisk.redesign.superuser.diffListOf
import
com.topjohnwu.magisk.redesign.superuser.diffListOf
...
@@ -27,6 +30,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
...
@@ -27,6 +30,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.disposables.Disposable
import
me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
import
me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
import
timber.log.Timber
import
timber.log.Timber
import
kotlin.math.roundToInt
class
ModuleViewModel
(
class
ModuleViewModel
(
private
val
repoName
:
RepoByNameDao
,
private
val
repoName
:
RepoByNameDao
,
...
@@ -72,6 +76,19 @@ class ModuleViewModel(
...
@@ -72,6 +76,19 @@ class ModuleViewModel(
// ---
// ---
init
{
RemoteFileService
.
reset
()
RemoteFileService
.
progressBroadcast
.
observeForever
{
val
(
progress
,
subject
)
=
it
?:
return
@observeForever
if
(
subject
!
is
DownloadSubject
.
Module
)
{
return
@observeForever
}
update
(
subject
.
module
,
progress
.
times
(
100
).
roundToInt
())
}
}
// ---
override
fun
refresh
()
=
Single
.
fromCallable
{
Module
.
loadModules
()
}
override
fun
refresh
()
=
Single
.
fromCallable
{
Module
.
loadModules
()
}
.
map
{
it
.
map
{
ModuleItem
(
it
)
}
}
.
map
{
it
.
map
{
ModuleItem
(
it
)
}
}
.
map
{
it
.
order
()
}
.
map
{
it
.
order
()
}
...
@@ -150,6 +167,11 @@ class ModuleViewModel(
...
@@ -150,6 +167,11 @@ class ModuleViewModel(
return
me
return
me
}
}
private
fun
update
(
repo
:
Repo
,
progress
:
Int
)
=
Single
.
fromCallable
{
itemsRemote
}
.
map
{
it
.
first
{
it
.
item
.
id
==
repo
.
id
}
}
.
subscribeK
{
it
.
progress
.
value
=
progress
}
.
add
()
// ---
// ---
@UiThread
@UiThread
...
...
app/src/main/res/layout/item_repo_md2.xml
View file @
027a5695
...
@@ -105,10 +105,29 @@
...
@@ -105,10 +105,29 @@
<ProgressBar
<ProgressBar
style=
"?styleProgressDeterminate"
style=
"?styleProgressDeterminate"
goneUnless=
"@{item.progress > 0 && item.progress < 100}"
progressAnimated=
"@{item.progress}"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
tools:progress=
"40"
/>
tools:progress=
"40"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
>
<androidx.core.widget.ContentLoadingProgressBar
style=
"?styleProgressIndeterminate"
goneUnless=
"@{item.progress == -100}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginTop=
"-4dp"
android:layout_marginBottom=
"-5dp"
tools:progress=
"40"
/>
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
</layout>
</layout>
...
...
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