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
893a8ec8
Commit
893a8ec8
authored
Aug 09, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip out most StaggeredGridLayoutManager in code
parent
da2b00de
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
43 deletions
+7
-43
ModuleRvItem.kt
...om/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt
+0
-14
PolicyRvItem.kt
...om/topjohnwu/magisk/model/entity/recycler/PolicyRvItem.kt
+0
-8
TextItem.kt
...va/com/topjohnwu/magisk/model/entity/recycler/TextItem.kt
+1
-9
ModuleFragment.kt
...ain/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
+2
-8
EndlessRecyclerScrollListener.kt
...m/topjohnwu/magisk/utils/EndlessRecyclerScrollListener.kt
+3
-3
fragment_superuser_md2.xml
app/src/main/res/layout/fragment_superuser_md2.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt
View file @
893a8ec8
...
...
@@ -2,8 +2,6 @@ package com.topjohnwu.magisk.model.entity.recycler
import
androidx.databinding.Bindable
import
androidx.databinding.Observable
import
androidx.databinding.ViewDataBinding
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.model.module.Module
...
...
@@ -16,12 +14,6 @@ import com.topjohnwu.magisk.utils.set
object
InstallModule
:
ComparableRvItem
<
InstallModule
>()
{
override
val
layoutRes
=
R
.
layout
.
item_module_download
override
fun
onBindingBound
(
binding
:
ViewDataBinding
)
{
super
.
onBindingBound
(
binding
)
val
params
=
binding
.
root
.
layoutParams
as
?
StaggeredGridLayoutManager
.
LayoutParams
params
?.
isFullSpan
=
true
}
override
fun
contentSameAs
(
other
:
InstallModule
)
=
this
==
other
override
fun
itemSameAs
(
other
:
InstallModule
)
=
this
===
other
}
...
...
@@ -45,12 +37,6 @@ class SectionTitle(
var
hasButton
=
_button
!=
0
&&
_icon
!=
0
set
(
value
)
=
set
(
value
,
field
,
{
field
=
it
},
BR
.
hasButton
)
override
fun
onBindingBound
(
binding
:
ViewDataBinding
)
{
super
.
onBindingBound
(
binding
)
val
params
=
binding
.
root
.
layoutParams
as
?
StaggeredGridLayoutManager
.
LayoutParams
params
?.
isFullSpan
=
true
}
override
fun
itemSameAs
(
other
:
SectionTitle
):
Boolean
=
this
===
other
override
fun
contentSameAs
(
other
:
SectionTitle
):
Boolean
=
this
===
other
}
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/PolicyRvItem.kt
View file @
893a8ec8
...
...
@@ -2,8 +2,6 @@ package com.topjohnwu.magisk.model.entity.recycler
import
android.graphics.drawable.Drawable
import
androidx.databinding.Bindable
import
androidx.databinding.ViewDataBinding
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.model.MagiskPolicy
...
...
@@ -60,12 +58,6 @@ class PolicyItem(val item: MagiskPolicy, val icon: Drawable) : ObservableItem<Po
viewModel
.
updatePolicy
(
updatedPolicy
,
isLogging
=
true
)
}
override
fun
onBindingBound
(
binding
:
ViewDataBinding
)
{
super
.
onBindingBound
(
binding
)
val
params
=
binding
.
root
.
layoutParams
as
?
StaggeredGridLayoutManager
.
LayoutParams
params
?.
isFullSpan
=
true
}
override
fun
contentSameAs
(
other
:
PolicyItem
)
=
itemSameAs
(
other
)
override
fun
itemSameAs
(
other
:
PolicyItem
)
=
item
.
uid
==
other
.
item
.
uid
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/TextItem.kt
View file @
893a8ec8
package
com.topjohnwu.magisk.model.entity.recycler
import
androidx.databinding.ViewDataBinding
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.databinding.ComparableRvItem
class
TextItem
(
val
text
:
Int
)
:
ComparableRvItem
<
TextItem
>()
{
override
val
layoutRes
=
R
.
layout
.
item_text
override
fun
onBindingBound
(
binding
:
ViewDataBinding
)
{
super
.
onBindingBound
(
binding
)
val
params
=
binding
.
root
.
layoutParams
as
?
StaggeredGridLayoutManager
.
LayoutParams
params
?.
isFullSpan
=
true
}
override
fun
contentSameAs
(
other
:
TextItem
)
=
text
==
other
.
text
override
fun
itemSameAs
(
other
:
TextItem
)
=
contentSameAs
(
other
)
}
\ No newline at end of file
}
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleFragment.kt
View file @
893a8ec8
...
...
@@ -8,15 +8,14 @@ import android.view.MenuItem
import
android.view.View
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
import
com.topjohnwu.magisk.ktx.hideKeyboard
import
com.topjohnwu.magisk.model.events.InstallExternalModuleEvent
import
com.topjohnwu.magisk.model.events.ViewEvent
import
com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.ui.base.ReselectionTarget
import
com.topjohnwu.magisk.ui.base.BaseUIFragment
import
com.topjohnwu.magisk.ui.base.ReselectionTarget
import
com.topjohnwu.magisk.utils.EndlessRecyclerScrollListener
import
com.topjohnwu.magisk.utils.MotionRevealHelper
import
org.koin.androidx.viewmodel.ext.android.viewModel
...
...
@@ -112,12 +111,7 @@ class ModuleFragment : BaseUIFragment<ModuleViewModel, FragmentModuleMd2Binding>
override
fun
onReselected
()
{
binding
.
moduleList
.
takeIf
{
(
it
.
layoutManager
as
?
StaggeredGridLayoutManager
)
?.
let
{
it
.
findFirstVisibleItemPositions
(
IntArray
(
it
.
spanCount
)).
min
()
}
?:
0
>
10
}
?.
also
{
it
.
scrollToPosition
(
10
)
}
.
also
{
it
.
scrollToPosition
(
10
)
}
.
let
{
binding
.
moduleList
}
.
also
{
it
.
post
{
it
.
smoothScrollToPosition
(
0
)
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/EndlessRecyclerScrollListener.kt
View file @
893a8ec8
...
...
@@ -54,8 +54,8 @@ class EndlessRecyclerScrollListener(
val
visibleItemPosition
=
if
(
direction
==
Direction
.
BOTTOM
)
{
when
(
layoutManager
)
{
is
StaggeredGridLayoutManager
->
layoutManager
.
findLastVisibleItemPositions
(
null
).
max
()
?:
0
is
StaggeredGridLayoutManager
->
layoutManager
.
findLastVisibleItemPositions
(
null
).
max
()
?:
0
is
GridLayoutManager
->
layoutManager
.
findLastVisibleItemPosition
()
is
LinearLayoutManager
->
layoutManager
.
findLastVisibleItemPosition
()
else
->
throw
IllegalArgumentException
(
"Only LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager are supported"
)
...
...
@@ -113,4 +113,4 @@ class EndlessRecyclerScrollListener(
}
class
ResetState
:
ViewEvent
()
}
\ No newline at end of file
}
app/src/main/res/layout/fragment_superuser_md2.xml
View file @
893a8ec8
...
...
@@ -32,7 +32,7 @@
android:paddingStart=
"@dimen/l1"
android:paddingTop=
"@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l1}"
android:paddingBottom=
"@{viewModel.insets.bottom + (int) @dimen/l2}"
app:layoutManager=
"androidx.recyclerview.widget.
StaggeredGrid
LayoutManager"
app:layoutManager=
"androidx.recyclerview.widget.
Linear
LayoutManager"
app:spanCount=
"2"
tools:layout_marginTop=
"24dp"
tools:listitem=
"@layout/item_policy_md2"
...
...
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