Minor code cleanup
This commit is contained in:
@@ -31,7 +31,7 @@ class AnilistLoginActivity : AppCompatActivity() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
returnToSettings()
|
||||
}, { _ ->
|
||||
}, {
|
||||
returnToSettings()
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -61,14 +61,16 @@ inline fun <P : Preference> PreferenceGroup.initThenAdd(p: P, block: P.() -> Uni
|
||||
return p.apply {
|
||||
block()
|
||||
this.isIconSpaceReserved = false
|
||||
addPreference(this) }
|
||||
addPreference(this)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <P : Preference> PreferenceGroup.addThenInit(p: P, block: P.() -> Unit): P {
|
||||
return p.apply {
|
||||
this.isIconSpaceReserved = false
|
||||
addPreference(this)
|
||||
block() }
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun Preference.onClick(crossinline block: () -> Unit) {
|
||||
|
||||
@@ -206,7 +206,7 @@ class SettingsBackupController : SettingsController() {
|
||||
.content(R.string.backup_choice)
|
||||
.items(options)
|
||||
.itemsDisabledIndices(0)
|
||||
.itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4), { _, positions, _ ->
|
||||
.itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4)) { _, positions, _ ->
|
||||
var flags = 0
|
||||
for (i in 1 until positions.size) {
|
||||
when (positions[i]) {
|
||||
@@ -219,7 +219,7 @@ class SettingsBackupController : SettingsController() {
|
||||
|
||||
(targetController as? SettingsBackupController)?.createBackup(flags)
|
||||
true
|
||||
})
|
||||
}
|
||||
.positiveText(R.string.action_create)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
|
||||
@@ -147,7 +147,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
.items(externalDirs)
|
||||
.itemsCallbackSingleChoice(selectedIndex, { _, _, which, text ->
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, _, which, text ->
|
||||
val target = targetController as? SettingsDownloadController
|
||||
if (which == externalDirs.lastIndex) {
|
||||
target?.customDirectorySelected(currentDir)
|
||||
@@ -155,7 +155,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
target?.predefinedDirectorySelected(text.toString())
|
||||
}
|
||||
true
|
||||
})
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ class SettingsGeneralController : SettingsController() {
|
||||
|
||||
Observable.combineLatest(
|
||||
preferences.portraitColumns().asObservable(),
|
||||
preferences.landscapeColumns().asObservable(),
|
||||
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
||||
preferences.landscapeColumns().asObservable()
|
||||
) { portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) }
|
||||
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
||||
val portrait = getColumnValue(portraitCols)
|
||||
val landscape = getColumnValue(landscapeCols)
|
||||
|
||||
Reference in New Issue
Block a user