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
cae43b26
Commit
cae43b26
authored
Jan 17, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve settings item code
parent
b95cf9b9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
116 deletions
+59
-116
SettingsItem.kt
...om/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt
+4
-19
SettingsItems.kt
...in/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
+55
-97
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/SettingsItem.kt
View file @
cae43b26
...
@@ -28,7 +28,7 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
...
@@ -28,7 +28,7 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
@get
:
Bindable
@get
:
Bindable
var
isEnabled
by
bindable
(
true
,
BR
.
enabled
)
var
isEnabled
by
bindable
(
true
,
BR
.
enabled
)
protected
open
val
isFullSpan
:
Boolean
=
false
protected
open
val
isFullSpan
get
()
=
false
@CallSuper
@CallSuper
open
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
open
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
...
@@ -145,28 +145,13 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
...
@@ -145,28 +145,13 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
protected
val
resources
get
()
=
get
<
Resources
>()
protected
val
resources
get
()
=
get
<
Resources
>()
var
entries
:
Array
<
out
CharSequence
>
=
arrayOf
()
abstract
val
entries
:
Array
<
out
CharSequence
>
private
set
abstract
val
entryValues
:
Array
<
out
CharSequence
>
var
entryValues
:
Array
<
out
CharSequence
>
=
arrayOf
()
private
set
@get
:
Bindable
@get
:
Bindable
val
selectedEntry
val
selectedEntry
get
()
=
entries
.
getOrNull
(
value
)
get
()
=
entries
.
getOrNull
(
value
)
fun
setValues
(
entries
:
Array
<
out
CharSequence
>,
values
:
Array
<
out
CharSequence
>
)
{
check
(
entries
.
size
<=
values
.
size
)
{
"List sizes must match"
}
this
.
entries
=
entries
this
.
entryValues
=
values
notifyChange
(
BR
.
selectedEntry
)
}
override
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
override
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
if
(
entries
.
isEmpty
()
||
entryValues
.
isEmpty
())
return
if
(
entries
.
isEmpty
()
||
entryValues
.
isEmpty
())
return
callback
.
onItemPressed
(
view
,
this
)
callback
.
onItemPressed
(
view
,
this
)
...
@@ -199,7 +184,7 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
...
@@ -199,7 +184,7 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
abstract
class
Section
:
SettingsItem
()
{
abstract
class
Section
:
SettingsItem
()
{
override
val
layoutRes
=
R
.
layout
.
item_settings_section
override
val
layoutRes
=
R
.
layout
.
item_settings_section
override
val
isFullSpan
=
true
override
val
isFullSpan
get
()
=
true
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
View file @
cae43b26
This diff is collapsed.
Click to expand it.
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